Permalink
Browse files

gradebook MDL-25713 switched grade_object fetch_all_helper() over to …

…using a recordset
  • Loading branch information...
1 parent 88e5c58 commit 2f9ea7d78e70f944c40739be2ed1a812a4b5d05f @andyjdavis andyjdavis committed Dec 20, 2010
Showing with 13 additions and 12 deletions.
  1. +13 −12 lib/grade/grade_object.php
@@ -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;
}
/**

0 comments on commit 2f9ea7d

Please sign in to comment.