]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-14679 fixed get_in_or_equal() method
authorskodak <skodak>
Sat, 24 May 2008 13:05:34 +0000 (13:05 +0000)
committerskodak <skodak>
Sat, 24 May 2008 13:05:34 +0000 (13:05 +0000)
lib/dml/moodle_database.php

index 503b501b79b0f8c6cf48a05262d87e150d55dcae..0eb12b91c3b05896707fee1667c1fd0533a40235 100644 (file)
@@ -143,16 +143,21 @@ abstract class moodle_database {
         if ($type == SQL_PARAMS_QM) {
             if (!is_array($items) or count($items) == 1) {
                 $sql = '= ?';
-                $params = array($items);
+                $items = (array)$items;
+                $params = array_values($items);
             } else {
                 $sql = 'IN ('.implode(',', array_fill(0, count($items), '?')).')';
                 $params = array_values($items);
             }
 
         } else if ($type == SQL_PARAMS_NAMED) {
-            if (!is_array($items) or count($items) == 1) {
+            if (!is_array($items)){
                 $sql = '= :'.$start;
                 $params = array($start=>$items);
+            } else if (count($items) == 1) {
+                $sql = '= :'.$start;
+                $item = reset($items);
+                $params = array($start=>$item);
             } else {
                 $params = array();
                 $sql = array();