Browse files

Merge branch 'MDL-25713_m2_recordset'

  • Loading branch information...
2 parents f140ee3 + c3b1c4f commit 3b8929e84b345a69425af8b25050f08f1163b98a @skodak skodak committed Dec 27, 2010
Showing with 14 additions and 12 deletions.
  1. +14 −12 lib/grade/grade_object.php
View
26 lib/grade/grade_object.php
@@ -184,20 +184,22 @@ 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()) {
+ $rs->close();
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 3b8929e

Please sign in to comment.