From: skodak Date: Sat, 24 May 2008 13:05:34 +0000 (+0000) Subject: MDL-14679 fixed get_in_or_equal() method X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=1d2b7f03cdf29494c04605511e232155bc516a8d;p=moodle.git MDL-14679 fixed get_in_or_equal() method --- diff --git a/lib/dml/moodle_database.php b/lib/dml/moodle_database.php index 503b501b79..0eb12b91c3 100644 --- a/lib/dml/moodle_database.php +++ b/lib/dml/moodle_database.php @@ -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();