mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
MDL-14679 detect incorrect key=>value pairs in $conditions - in case somebody forgets "=>" and uses "," instead
This commit is contained in:
parent
d251907c51
commit
c74a123781
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user