public function updateRecord($type, $updatevalues, $id = NULL)
{
$table = $type;
if (!$id) {
$insertcolumns = $insertvalues = array();
foreach ($updatevalues as $pair) {
$insertcolumns[] = $pair['property'];
$insertvalues[] = $pair['value'];
}
//Otherwise psql returns string while MySQL/SQLite return numeric causing problems with additions (array_diff)
return (string) $this->insertRecord($table, $insertcolumns, array($insertvalues));
}
if ($id && !count($updatevalues)) {
return $id;
}
$table = $this->esc($table);
$sql = "UPDATE {$table} SET ";
$p = $v = array();
foreach ($updatevalues as $uv) {
if (isset(self::$sqlFilters['w'][$type][$uv['property']])) {
$p[] = " {$this->esc($uv["property"])} = " . self::$sqlFilters['w'][$type][$uv['property']];
} else {
$p[] = " {$this->esc($uv["property"])} = ? ";
}
$v[] = $uv['value'];
}
$sql .= implode(',', $p) . ' WHERE id = ? ';
$v[] = $id;
$this->adapter->exec($sql, $v);
return $id;
}