mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
MDL-30147 dml - mysql and no params now behaving "standard"
This commit is contained in:
parent
a8097d6dda
commit
870896eca1
2 changed files with 19 additions and 17 deletions
|
@ -495,26 +495,21 @@ abstract class moodle_database {
|
|||
* @return array sql part and params
|
||||
*/
|
||||
protected function where_clause($table, array $conditions=null) {
|
||||
$allowed_types = $this->allowed_param_types();
|
||||
if (empty($conditions)) {
|
||||
return array('', array());
|
||||
}
|
||||
$where = array();
|
||||
$params = array();
|
||||
|
||||
// We accept nulls in conditions
|
||||
$conditions = is_null($conditions) ? array() : $conditions;
|
||||
// Some checks performed under debugging only
|
||||
if (debugging()) {
|
||||
$columns = $this->get_columns($table);
|
||||
if (empty($columns)) {
|
||||
// no supported columns means most probably table does not exist
|
||||
throw new dml_exception('ddltablenotexist', $table);
|
||||
}
|
||||
foreach ($conditions as $key=>$value) {
|
||||
if (!isset($columns[$key])) {
|
||||
if (empty($columns)) {
|
||||
// no supported columns means most probably table does not exist
|
||||
throw new dml_exception('ddltablenotexist', $table);
|
||||
} else {
|
||||
$a = new stdClass();
|
||||
$a->fieldname = $key;
|
||||
$a->tablename = $table;
|
||||
throw new dml_exception('ddlfieldnotexist', $a);
|
||||
}
|
||||
$a = new stdClass();
|
||||
$a->fieldname = $key;
|
||||
$a->tablename = $table;
|
||||
throw new dml_exception('ddlfieldnotexist', $a);
|
||||
}
|
||||
$column = $columns[$key];
|
||||
if ($column->meta_type == 'X') {
|
||||
|
@ -524,6 +519,13 @@ abstract class moodle_database {
|
|||
}
|
||||
}
|
||||
|
||||
$allowed_types = $this->allowed_param_types();
|
||||
if (empty($conditions)) {
|
||||
return array('', array());
|
||||
}
|
||||
$where = array();
|
||||
$params = array();
|
||||
|
||||
foreach ($conditions as $key=>$value) {
|
||||
if (is_int($key)) {
|
||||
throw new dml_exception('invalidnumkey');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue