Bluz\Db\Table::update PHP Метод

update() публичный статический Метод

Table::insert(['login' => 'Man', 'email' => '[email protected]'], ['id' => 42])
public static update ( array $data, array $where ) : integer
$data array Column-value pairs.
$where array An array of SQL WHERE clause(s)
Результат integer The number of rows updated
    public static function update(array $data, array $where)
    {
        if (!sizeof($where)) {
            throw new DbException("Method `Table::update()` can't update all records in table,\n" . "please use `Db::query()` instead (of cause if you know what are you doing)");
        }
        $self = static::getInstance();
        $data = $self->filterColumns($data);
        $where = $self->filterColumns($where);
        if (!sizeof($data) || !sizeof($where)) {
            throw new DbException("Invalid field names of table `{$self->table}`. Please check use of `update()` method");
        }
        $table = DbProxy::quoteIdentifier($self->table);
        $sql = "UPDATE {$table}" . " SET " . join(',', self::prepareStatement($data)) . " WHERE " . join(' AND ', self::prepareStatement($where));
        return DbProxy::query($sql, array_merge(array_values($data), array_values($where)));
    }