mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +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,27 +495,22 @@ abstract class moodle_database {
|
||||||
* @return array sql part and params
|
* @return array sql part and params
|
||||||
*/
|
*/
|
||||||
protected function where_clause($table, array $conditions=null) {
|
protected function where_clause($table, array $conditions=null) {
|
||||||
$allowed_types = $this->allowed_param_types();
|
// We accept nulls in conditions
|
||||||
if (empty($conditions)) {
|
$conditions = is_null($conditions) ? array() : $conditions;
|
||||||
return array('', array());
|
// Some checks performed under debugging only
|
||||||
}
|
|
||||||
$where = array();
|
|
||||||
$params = array();
|
|
||||||
|
|
||||||
if (debugging()) {
|
if (debugging()) {
|
||||||
$columns = $this->get_columns($table);
|
$columns = $this->get_columns($table);
|
||||||
foreach ($conditions as $key=>$value) {
|
|
||||||
if (!isset($columns[$key])) {
|
|
||||||
if (empty($columns)) {
|
if (empty($columns)) {
|
||||||
// no supported columns means most probably table does not exist
|
// no supported columns means most probably table does not exist
|
||||||
throw new dml_exception('ddltablenotexist', $table);
|
throw new dml_exception('ddltablenotexist', $table);
|
||||||
} else {
|
}
|
||||||
|
foreach ($conditions as $key=>$value) {
|
||||||
|
if (!isset($columns[$key])) {
|
||||||
$a = new stdClass();
|
$a = new stdClass();
|
||||||
$a->fieldname = $key;
|
$a->fieldname = $key;
|
||||||
$a->tablename = $table;
|
$a->tablename = $table;
|
||||||
throw new dml_exception('ddlfieldnotexist', $a);
|
throw new dml_exception('ddlfieldnotexist', $a);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
$column = $columns[$key];
|
$column = $columns[$key];
|
||||||
if ($column->meta_type == 'X') {
|
if ($column->meta_type == 'X') {
|
||||||
//ok so the column is a text column. sorry no text columns in the where clause conditions
|
//ok so the column is a text column. sorry no text columns in the where clause conditions
|
||||||
|
@ -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) {
|
foreach ($conditions as $key=>$value) {
|
||||||
if (is_int($key)) {
|
if (is_int($key)) {
|
||||||
throw new dml_exception('invalidnumkey');
|
throw new dml_exception('invalidnumkey');
|
||||||
|
|
|
@ -435,7 +435,7 @@ class mysqli_native_moodle_database extends moodle_database {
|
||||||
$sql = "SHOW COLUMNS FROM {$this->prefix}$table";
|
$sql = "SHOW COLUMNS FROM {$this->prefix}$table";
|
||||||
$this->query_start($sql, null, SQL_QUERY_AUX);
|
$this->query_start($sql, null, SQL_QUERY_AUX);
|
||||||
$result = $this->mysqli->query($sql);
|
$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) {
|
if ($result === false) {
|
||||||
return array();
|
return array();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue