From 1d2b7f03cdf29494c04605511e232155bc516a8d Mon Sep 17 00:00:00 2001 From: skodak Date: Sat, 24 May 2008 13:05:34 +0000 Subject: [PATCH] MDL-14679 fixed get_in_or_equal() method --- lib/dml/moodle_database.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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(); -- 2.39.5