MDL-30147 dml - mysql and no params now behaving "standard"

This commit is contained in:
Eloy Lafuente (stronk7) 2011-11-12 22:27:24 +01:00 committed by Petr Skoda
parent a8097d6dda
commit 870896eca1
2 changed files with 19 additions and 17 deletions

View file

@ -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');

View file

@ -435,7 +435,7 @@ class mysqli_native_moodle_database extends moodle_database {
$sql = "SHOW COLUMNS FROM {$this->prefix}$table";
$this->query_start($sql, null, SQL_QUERY_AUX);
$result = $this->mysqli->query($sql);
$this->query_end($result);
$this->query_end(true); // Don't want to throw anything here ever. MDL-30147
if ($result === false) {
return array();