Skip to content

Commit

Permalink
MDL-55136 data_object: fix param handling in fetch_all_helper
Browse files Browse the repository at this point in the history
  • Loading branch information
davosmith committed Jul 6, 2016
1 parent ac8d6cf commit a106fb8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions completion/data_object.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ public static function fetch_all_helper($table, $classname, $params) {

$wheresql = array();

$dbparams = array();
foreach ($params as $var=>$value) {
if (!in_array($var, $instance->required_fields) and !array_key_exists($var, $instance->optional_fields)) {
continue;
Expand All @@ -221,7 +222,7 @@ public static function fetch_all_helper($table, $classname, $params) {
$wheresql[] = " $var IS NULL ";
} else {
$wheresql[] = " $var = ? ";
$params[] = $value;
$dbparams[] = $value;
}
}

Expand All @@ -232,7 +233,7 @@ public static function fetch_all_helper($table, $classname, $params) {
}

global $DB;
if ($datas = $DB->get_records_select($table, $wheresql, $params)) {
if ($datas = $DB->get_records_select($table, $wheresql, $dbparams)) {

$result = array();
foreach($datas as $data) {
Expand Down

0 comments on commit a106fb8

Please sign in to comment.