Drivers\Abstraction\Sql::update PHP Method

update() public method

Abstraction for update.
public update ( string $table, array $dat, array $where = null ) : boolean
$table string
$dat array
$where array
return boolean
    public function update($table, $dat, $where = null)
    {
        foreach ($dat as $key => $val) {
            $data[$key] = $this->escape($val);
        }
        $bits = $wheres = array();
        foreach ((array) array_keys($data) as $k) {
            $bits[] = "{$k} = '{$data[$k]}'";
        }
        if (!empty($this->criteria)) {
            $criteria = implode(' ', $this->criteria);
            unset($this->criteria);
        } elseif (is_array($where)) {
            foreach ($where as $c => $v) {
                $wheres[] = "{$c} = '" . $this->escape($v) . "'";
            }
            $criteria = implode(' AND ', $wheres);
        } else {
            return false;
        }
        return $this->query("UPDATE {$table} SET " . implode(', ', $bits) . ' WHERE ' . $criteria);
    }