]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-9960 update_record() does not store NULLs; I hope it will not break anything
authorskodak <skodak>
Mon, 28 May 2007 08:49:40 +0000 (08:49 +0000)
committerskodak <skodak>
Mon, 28 May 2007 08:49:40 +0000 (08:49 +0000)
lib/dmllib.php

index 27b74cb296aad98356c9d098b688200c68175744..767b6927f662f8ef9f894dfb7073df7abddd7652 100644 (file)
@@ -1538,7 +1538,7 @@ function update_record($table, $dataobject) {
     // Pull out data matching these fields
     $ddd = array();
     foreach ($columns as $column) {
-        if ($column->name <> 'id' and isset($data[$column->name]) ) {
+        if ($column->name <> 'id' and array_key_exists($column->name, $data)) {
             $ddd[$column->name] = $data[$column->name];
             // PostgreSQL bytea support
             if ($CFG->dbfamily == 'postgres' && $column->type == 'bytea') {
@@ -1557,7 +1557,11 @@ function update_record($table, $dataobject) {
     if ($numddd) {
         foreach ($ddd as $key => $value) {
             $count++;
-            $update .= $key .' = \''. $value .'\'';   // All incoming data is already quoted
+            if ($value === NULL) {
+                $update .= $key .' = NULL'; // previosly NULLs were not updated
+            } else {
+                $update .= $key .' = \''. $value .'\'';   // All incoming data is already quoted
+            }
             if ($count < $numddd) {
                 $update .= ', ';
             }