Update the record matching input parameters.
If no record is found, create a new one.

@param array $where
@param array $inputs

@return mixed
502400
public function updateOrCreateBy(array $where, array $inputs = [])
    {
        $inputs = $this->purifyInputs($inputs);

        $query = $this->make();

        $query = $this->applyWhere($query, $where);

        $model = $query->first();

        if ($model) {
            $model->update($inputs);

            return $model;
        } else {
            return $this->model->create($inputs);
        }
    }
424528
protected function prepareUpdate($table, $values, $where){
        $sql= 'UPDATE ' . $table . ' SET ';
        foreach ($values as $key => $value) {
            $sql .= $key . '=:' . $key . ',';
        }
        $sql = trim($sql, ',');
        if($where != ''){$sql.= " WHERE " . $where;}
        //Preparo la consulta y la retorno
        return  $this->connection->prepare($sql);
    }
800261
public function update($table, $feilds, array $where, $limit=0)
	{
		$set = array();
        $vals = array();

		foreach ($feilds as $key => $val) {
			$set[] = "`{$key}` = ?";
            $vals[] = $val;
		}

		$set = implode(', ', $set);

		$sql = "UPDATE {$table} SET {$set} WHERE " . $this->buildWhere($where, $vals);

        if ($limit > 0) {
            $sql .= " LIMIT ".(int)$limit;
        }

        $stmt = $this->prepare($sql);
        return $stmt ? $stmt->execute($vals) : false;
	}
922842
public function update(array $data, $where) {
        $this->notifyObservers('beforeUpdate', array($this, &$data, &$where));
        $result = parent::update($data, $where);
        $this->notifyObservers('afterUpdate', array($this, $result, $data, $where));
        return $result;
    }
1305650
public static function update($table, $data, $where) {
        $update = Update::table($table);
        foreach ($data as $field => $value) {
            $update->set($field, $value);
        }
        if (is_array($where)) {
            foreach ($where as $field => $value) {
                $update->where($field, $value);
            }
        } else {
            $update->where("id", $where);
        }
        $update->excuse();
    }
146078
public static function find(array $where) {
        $model = get_called_class();
        /* @var $t Record */
        $t = new $model;
        /* @var $db_cache DBCache */
        $db_cache = Ioc::get(DBCache::class);
        $data = $db_cache->recordWhereCache($model, $where);
        if ($data) {
            return $data;
        }
        /* @var $data Record */
        $select = DB::select($t->getTable())->where($where)->setRecord($model);
        Event::trigger('record_before_select', [$t, $select]);
        $data = $select->find();
        $db_cache->recordWhereCacheSave($model, $where, $data->_db_data);
        return $data;
    }
521412
public static function update(array $data, array $where): int
    {
        $self = static::getInstance();

        $data = static::filterColumns($data);

        if (!\count($data)) {
            throw new DbException(
                "Invalid field names of table `{$self->name}`. Please check use of `update()` method"
            );
        }

        $where = static::filterColumns($where);

        if (!\count($where)) {
            throw new DbException(
                "Method `Table::update()` can't update all records in the table `{$self->name}`,\n" .
                "please use `Db::query()` instead (of cause if you know what are you doing)"
            );
        }

        $table = DbProxy::quoteIdentifier($self->name);

        $sql = "UPDATE $table SET " . implode(',', self::prepareStatement($data))
            . " WHERE " . implode(' AND ', self::prepareStatement($where));

        return DbProxy::query($sql, array_merge(array_values($data), array_values($where)));
    }
706606
public function update($id, $input)
    {
        $this->model = $this->model->query()->findOrFail($id);

        $this->model = $this->model->fill($input);

        $filteredInput = $this->runChecks('update', $this->model->toArray(), $this->model->getOriginal());

        if ($filteredInput) {
            $this->model->fill($filteredInput);
        }

        return $this->model->save();
    }
467248
public function update(array $data, $where, $table = null)
    {
        $table = ($table) ?: $this->getTable();
        $sql = $this->getSql();
        $update = $sql->update($table);

        $update->set($data)
            ->where($where);

        $statement = $sql->prepareStatementForSqlObject($update);
        $result = $statement->execute();

        return $result->getAffectedRows();
    }
765248
public function edit($objects, $whereFilters) {
        $dbConfigList = array();
        foreach ($objects as $object) {
            $dbConfig = new DbStatementConfig($object);
            $dbConfig->setTableName($this->GetTableName($object));
            $dbConfig->setType(DbExecutionType::UPDATE);
            $dbConfig->Bui($this->BuildClauseStatement($object));
            $dbConfig->setWhereClause($this->BuildClauseStatement($object, $whereFilters));
            $dbConfig->BuildUpdateQuery();
            $this->addDbConfigItem($dbConfig);
        }
        return $this->BindParametersAndExecute($whereFilters);
    }
1015057
private static function smartUpdate($table, $fields, $where) {
        $table = self::sanitizeKey($table);
        $fieldsString = self::setFields($fields);
        $whereString = self::handleConditions($where);
        $sql = 'UPDATE ' . self::$_ops->addBackticks($table) . ' SET ' . $fieldsString . $whereString;

        return self::handleResults($sql);
    }
931254
public function update(Array $where, Array $updateData)
    {
        $param = $set = '';
        foreach ($where as $key => $value) {
            if (is_int($key)) { //如果下标是数字，则不用下标拼装sql
                $param .= $value . ' AND ';
            } else {
                $param .= "$key='$value' AND ";
            }
        }
        $param = substr($param, 0, -4);

        foreach ($updateData as $key => $value) { //拼装set
            if (is_int($key)) {
                $set .= $value . ',';
            } else {
                $set .= "$key='$value',";
            }
        }
        $set = substr($set, 0, -1);
        $this->sql = "UPDATE {$this->_table} SET $set WHERE $param";
        return $this->execute()->rowCount();

    }
811415
public function updateBatch(array $sets, array $where = [])
    {
        $this->where($where);
        $this->builderCache->store('sets', $sets);

        return $this->platformUpdateBatchHandler($this->builderCache);
    }
478708
public function updateItem(array $where, array $values){
        return $this->items()->where($where)->first()->update($values);
    }
948288
public function addWhere(array $where): void
    {
        if (empty($where)) {
            return;
        }

        $firstClause = true;
        $this->statement .= ' WHERE ';
        foreach ($where as $clause) {
            if ($firstClause === false) {
                $this->statement .= ' ' . $clause['concatenator'] . ' ';
            }
            switch ($clause['operator']) {
                case 'IN':
                    $this->addWhereIn($clause['key'], $clause['value'], false);
                    break;
                case 'NOT IN':
                    $this->addWhereIn($clause['key'], $clause['value'], true);
                    break;
                case 'BETWEEN':
                    $this->addWhereBetween($clause['key'], $clause['value']['min'], $clause['value']['max']);
                    break;
                case 'NULL':
                    $this->addWhereNull($clause['key'], false);
                    break;
                case 'NOT NULL':
                    $this->addWhereNull($clause['key'], true);
                    break;
                default:
                    $this->addSimpleWhere($clause['key'], $clause['operator'], $clause['value']);
                    break;
            }

            $firstClause = false;
        }
    }
681803
public function update($table, $data, $statements, $where)
    {
        $query = 'UPDATE `' . $table . '`  SET ';

        foreach ($data as $column => $value) {
            $value = (is_null($statements) && is_string($value)) ? "'$value'" : $value;
            $query .= $column . '=' . $value . ', ';
        }

        $query = rtrim(trim($query), ',');

        $query .= (! is_null($where)) ? ' WHERE ' : '';

        $query .= (is_string($where)) ? $where . ' ' : '';

        if (is_array($where)) {
            foreach ($where as $clause) {
                $query .= $clause . ' AND ';
            }
            $query = rtrim(trim($query), 'AND');
        }

        if (! is_null($statements) && is_array($statements)) {
            return $this->statements($query, $statements);
        }

        return $this->query($query, 'INSERT');
    }
95818
public function update(array $inputs)
    {
        $inputs = $this->purifyInputs($inputs);

        return $this->model->update($inputs);
    }