From: skodak Date: Mon, 28 May 2007 08:49:40 +0000 (+0000) Subject: MDL-9960 update_record() does not store NULLs; I hope it will not break anything X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=37db0ab8f8c4e658ec6ae9620a7cbc3d0441f58f;p=moodle.git MDL-9960 update_record() does not store NULLs; I hope it will not break anything --- diff --git a/lib/dmllib.php b/lib/dmllib.php index 27b74cb296..767b6927f6 100644 --- a/lib/dmllib.php +++ b/lib/dmllib.php @@ -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 .= ', '; }