]> git.mjollnir.org Git - moodle.git/commitdiff
Improvements to sql_bitand, etc. so that the caller does not have to worry about...
authortjhunt <tjhunt>
Fri, 27 Jul 2007 09:24:20 +0000 (09:24 +0000)
committertjhunt <tjhunt>
Fri, 27 Jul 2007 09:24:20 +0000 (09:24 +0000)
lib/dmllib.php

index 502dbd357530480ebb3938622674009590050341..ba657b8a5a2a2a3e8281e380b3c0a88d441d870c 100644 (file)
@@ -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 . '))';
     }
 }