Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed buglets in get_records_sql and insert_record

  • Loading branch information...
commit 5c0bef5d4632fca9fd5dfbaff95a4773cc2cf6d7 1 parent d3ca63f
martin authored
Showing with 9 additions and 6 deletions.
  1. +9 −6 lib/moodlelib.php
View
15 lib/moodlelib.php
@@ -437,11 +437,14 @@ function get_records_sql($sql) {
if (!$rs) return false;
if ( $rs->RecordCount() > 0 ) {
- $records = $rs->GetAssoc(true);
- foreach ($records as $key => $record) {
- $objects[$key] = (object) $record;
+ if ($records = $rs->GetAssoc(true)) {
+ foreach ($records as $key => $record) {
+ $objects[$key] = (object) $record;
+ }
+ return $objects;
+ } else {
+ return false;
}
- return $objects;
} else {
return false;
}
@@ -555,7 +558,7 @@ function update_record($table, $dataobject) {
global $db;
- if (! $dataobject->id) {
+ if (! isset($dataobject->id) ) {
return false;
}
@@ -565,7 +568,7 @@ function update_record($table, $dataobject) {
// Pull out data matching these fields
foreach ($columns as $column) {
- if ($column->name <> "id" && $data[$column->name] ) {
+ if ($column->name <> "id" && isset($data[$column->name]) ) {
$ddd[$column->name] = $data[$column->name];
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.