Skip to content

Commit

Permalink
gradebook MDL-25713 switched grade_object fetch_all_helper() over to …
Browse files Browse the repository at this point in the history
…using a recordset
  • Loading branch information
andyjdavis committed Dec 20, 2010
1 parent 88e5c58 commit 2f9ea7d
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions lib/grade/grade_object.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,20 +184,21 @@ public static function fetch_all_helper($table, $classname, $params) {
}

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

$result = array();
foreach($datas as $data) {
$instance = new $classname();
grade_object::set_properties($instance, $data);
$result[$instance->id] = $instance;
}
return $result;

} else {
$rs = $DB->get_recordset_select($table, $wheresql, $newparams);
//returning false rather than empty array if nothing found
if (!$rs->valid()) {
return false;
}

return false;
$result = array();
foreach($rs as $data) {
$instance = new $classname();
grade_object::set_properties($instance, $data);
$result[$instance->id] = $instance;
}
$rs->close();

return $result;
}

/**
Expand Down

0 comments on commit 2f9ea7d

Please sign in to comment.