Fix updating having Id in it
parent
e1c3584462
commit
51755b4f4e
|
@ -357,15 +357,16 @@ class ZM_Object {
|
|||
);
|
||||
}
|
||||
);
|
||||
$fields = array_keys($fields);
|
||||
|
||||
if ( $this->Id() ) {
|
||||
$fields = array_keys($fields);
|
||||
$sql = 'UPDATE `'.$table.'` SET '.implode(', ', array_map(function($field) {return '`'.$field.'`=?';}, $fields)).' WHERE Id=?';
|
||||
$values = array_map(function($field){ return $this->{$field};}, $fields);
|
||||
$values[] = $this->{'Id'};
|
||||
if (dbQuery($sql, $values)) return true;
|
||||
} else {
|
||||
unset($fields['Id']);
|
||||
$fields = array_keys($fields);
|
||||
|
||||
$sql = 'INSERT INTO `'.$table.
|
||||
'` ('.implode(', ', array_map(function($field) {return '`'.$field.'`';}, $fields)).
|
||||
|
|
Loading…
Reference in New Issue