Skip to content

Commit 1458b7a

Browse files
committed
Fix $db->update when there is null value
1 parent 3e00c52 commit 1458b7a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

system/libs/pot/OTS_Base_DB.php

+8-2
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,14 @@ public function update($table, $data, $where, $limit = 1)
167167
$query = 'UPDATE '.$this->tableName($table).' SET ';
168168

169169
$count = count($fields);
170-
for ($i = 0; $i < $count; $i++)
171-
$query.= $this->fieldName($fields[$i]).' = '.$this->quote($values[$i]).', ';
170+
for ($i = 0; $i < $count; $i++) {
171+
$value = 'NULL';
172+
if ($values[$i] !== null) {
173+
$value = $this->quote($values[$i]);
174+
}
175+
176+
$query.= $this->fieldName($fields[$i]).' = '.$value.', ';
177+
}
172178

173179
$query = substr($query, 0, -2);
174180
$query.=' WHERE (';

0 commit comments

Comments
 (0)