From: tjhunt Date: Fri, 27 Jul 2007 09:24:20 +0000 (+0000) Subject: Improvements to sql_bitand, etc. so that the caller does not have to worry about... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=a4bcb27f0e14e428c12af90ca7518eb696bfdd03;p=moodle.git Improvements to sql_bitand, etc. so that the caller does not have to worry about operator precidence. --- diff --git a/lib/dmllib.php b/lib/dmllib.php index 502dbd3575..ba657b8a5a 100644 --- a/lib/dmllib.php +++ b/lib/dmllib.php @@ -1822,10 +1822,10 @@ function sql_bitand($int1, $int2) { switch ($CFG->dbfamily) { case 'oracle': - return 'bitand(' . $int1 . ', ' . $int2 . ')'; + return 'bitand((' . $int1 . '), (' . $int2 . '))'; break; default: - return $int1 . ' & ' . $int2; + return '((' . $int1 . ') & (' . $int2 . '))'; } } @@ -1842,10 +1842,10 @@ function sql_bitor($int1, $int2) { switch ($CFG->dbfamily) { case 'oracle': - return '(' . $int1 . ' + ' . $int2 . ' - ' . sql_bitand($int1, $int2) . ')'; + return '((' . $int1 . ') + (' . $int2 . ') - ' . sql_bitand($int1, $int2) . ')'; break; default: - return $int1 . ' | ' . $int2; + return '((' . $int1 . ') | (' . $int2 . '))'; } } @@ -1865,10 +1865,10 @@ function sql_bitxor($int1, $int2) { return '(' . sql_bitor($int1, $int2) . ' - ' . sql_bitand($int1, $int2) . ')'; break; case 'postgres': - return $int1 . ' # ' . $int2; + return '((' . $int1 . ') # (' . $int2 . '))'; break; default: - return $int1 . ' ^ ' . $int2; + return '((' . $int1 . ') ^ (' . $int2 . '))'; } } @@ -1884,10 +1884,10 @@ function sql_bitnot($int1) { switch ($CFG->dbfamily) { case 'oracle': - return '(' . '(0 - ' . $int1 . ') - 1' . ')'; + return '((0 - (' . $int1 . ')) - 1)'; break; default: - return ' ~' . $int1; + return '(~(' . $int1 . '))'; } }