function update($table, $data, $where = array(), $params = array())
{
if (empty($data)) {
return;
}
$set = array();
foreach ($data as $column => $value) {
$set[] = $this->quoteIdentifier($column) . " = " . $this->quote($value);
}
if (!is_array($where)) {
$where = array($where);
}
if (!is_array($params)) {
$params = array_slice(func_get_args(), 3);
}
$table = $this->rewriteTable($table);
$query = "UPDATE " . $this->quoteIdentifier($table);
$query .= " SET " . implode(", ", $set);
$query .= $this->getSuffix($where);
$this->onQuery($query, $params);
$statement = $this->prepare($query);
$statement->execute($params);
return $statement;
}