verify where_clause() only in debug mode

This commit is contained in:
Petr Skoda
2011-08-05 21:34:09 +02:00
parent 80eb52c415
commit d84336c27d
+17 -12
View File
@@ -502,19 +502,24 @@ abstract class moodle_database {
$where = array();
$params = array();
$columns = $this->get_columns($table);
if (debugging()) {
$columns = $this->get_columns($table);
foreach ($conditions as $key=>$value) {
if (!isset($columns[$key])) {
$a = new stdClass();
$a->fieldname = $key;
$a->tablename = $table;
throw new dml_exception('ddlfieldnotexist', $a);
}
$column = $columns[$key];
if ($column->meta_type == 'X') {
//ok so the column is a text column. sorry no text columns in the where clause conditions
throw new dml_exception('textconditionsnotallowed', $conditions);
}
}
}
foreach ($conditions as $key=>$value) {
if (!isset($columns[$key])) {
$a = new stdClass();
$a->fieldname = $key;
$a->tablename = $table;
throw new dml_exception('ddlfieldnotexist', $a);
}
$column = $columns[$key];
if ($column->meta_type == 'X') {
//ok so the column is a text column. sorry no text columns in the where clause conditions
throw new dml_exception('textconditionsnotallowed', $conditions);
}
if (is_int($key)) {
throw new dml_exception('invalidnumkey');
}