From: skodak Date: Fri, 30 May 2008 16:56:43 +0000 (+0000) Subject: MDL-14679 detect incorrect key=>value pairs in $conditions - in case somebody forgets... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=c74a1237816cd0b30a414918ee3a367c6f91590c;p=moodle.git MDL-14679 detect incorrect key=>value pairs in $conditions - in case somebody forgets "=>" and uses "," instead --- diff --git a/lib/dml/moodle_database.php b/lib/dml/moodle_database.php index 85e7289dd1..f7bb9c4b6f 100644 --- a/lib/dml/moodle_database.php +++ b/lib/dml/moodle_database.php @@ -1187,6 +1187,11 @@ abstract class moodle_database { */ public abstract function sql_substr(); + /** + * Returns SQL WHERE conditions + * @param array conditions - must not contain numeric indexes + * @return array sql part and params + */ public function where_clause(array $conditions=null) { $allowed_types = $this->allowed_param_types(); if (empty($conditions)) { @@ -1195,6 +1200,9 @@ abstract class moodle_database { $where = array(); $params = array(); foreach ($conditions as $key=>$value) { + if (is_int($key)) { + error('$conditions array may not contain numeric keys, please fix the code!'); + } if (is_null($value)) { $where[] = "$key IS NULL"; } else {