Update a record in the database.

@param  array $values

@return int
429510
public function update(array $values)
    {
        $result = parent::update($values);

        $this->handler->setBuilder($this)
            ->invalidateQuery(Reflector::QUERY_TYPE_UPDATE, $values);

        return $result;
    }
1258032
public function setValues(array $values)
    {
        foreach ($values as $name => $value) {
            $this->fields->set($name, $value);
        }

        return $this;
    }
950636
public function insert(array $values)
    {
        // Since every insert gets treated like a batch insert, we will have to detect
        // if the user is inserting a single document or an array of documents.
        $batch = true;

        foreach ($values as $value) {
            // As soon as we find a value that is not an array we assume the user is
            // inserting a single document.
            if (!is_array($value)) {
                $batch = false;
                break;
            }
        }

        if (!$batch) {
            $values = [$values];
        }

        // Batch insert
        $result = $this->collection->insertMany($values);

        return (1 == (int) $result->isAcknowledged());
    }
1094084
public function insert(array $values)
    {
        $result = $this->getBuilder()->insert($values);

        // Reset query builder
        $this->resetBuilder();

        return $result;
    }
122885
protected static function checkUpdate(array $values)
    {
        $errors = [];
        foreach ($values as $key => $value) {
            $errors += static::checkProperty($key, $value);
        }
        return $errors;
    }
1237570
public function update(array $values)
    {
        if (!$this->hasId()) {
            throw new UpdateException('ID not set - did you call find($id) before update($values)?');
        }

        if (!$this->isUpdatable()) {
            throw new UpdateException('Permission denied: Entity can not be updated');
        }

        $this->transactional(function () use ($values) {
            $this->forceUpdate($values);
        });

        return $this;
    }
1242280
public function addValues(array $values)
    {
        // Check if this is a multi-dimensional array
        $isMultiDimensional = 0 == count($values) || (isset($values[0]) && is_array($values[0]));

        if ($isMultiDimensional) {
            $this->insertRows = array_merge($this->insertRows, $values);
        } else {
            // If a single row is provided then it is added
            // to the last row, or a new row if there are none.
            // This is done to maintain BC
            if (count($this->insertRows) > 0) {
                $k = count($this->insertRows) - 1;
                $this->insertRows[$k] = array_replace($this->insertRows[$k], $values);
            } else {
                $this->insertRows = [$values];
            }
        }

        return $this;
    }
630674
public function values(array $values)
    {
        $this->sqlParts['values'] = is_array(current($values)) ? $values : [$values];

        return $this;
    }
226475
public function buildUpdateSQL(array $values) {
		if(count($values) == 0)
			throw new \Exception('Update values should not be empty.');
		$params = [];

		if($this->db->getPDO()->getAttribute(\PDO::ATTR_DRIVER_NAME) === 'mysql') {
			list($jointures, $joinparams) = $this->buildJointures();
			$params = $joinparams;

			$set = [];
			foreach($values as $k=>$v) {
				if($v instanceof static) {
					$sql = $v->buildSQL();
					$params = array_merge($params, $v->getParameters());
					$set[] = $this->replace($k).'=('.$sql.')';
				}
				elseif($v instanceof Raw) {
					$sql = $v->getSQL();
					$params = array_merge($params, $v->getParameters());
					$set[] = $this->replace($k).'='.$sql;
				}
				else {
					$params[] = $v;
					$set[] = $this->replace($k).'=?';
				}
			}
			$str = ' SET '.implode(', ', $set);

			list($tables, $tableparams) = $this->buildTables(true);
			$params = array_merge($params, $tableparams);

			#can't mix order by and joins in update
			if($this->joins)
				$orderBy = '';
			else {
				list($orderBy, $orderByParams) = $this->buildOrderBy();
				$params = array_merge($params, $orderByParams);
			}
			$limit = $this->buildLimit();

			list($where, $whereparams) = $this->buildWhere();
			$params = array_merge($params, $whereparams);
			$sql = 'UPDATE '.$tables.$jointures.$str.$where.$orderBy.$limit;
		}
		elseif($this->joins || $this->limit || $this->offset) {
			$set = [];
			foreach($values as $k=>$v) {
				if($v instanceof static) {
					$sql = $v->buildSQL();
					$params = array_merge($params, $v->getParameters());
					$set[] = $this->replace($k, false).'=('.$sql.')';
				}
				elseif($v instanceof Raw) {
					$sql = $v->getSQL();
					$params = array_merge($params, $v->getParameters());
					$set[] = $this->replace($k, false).'='.$sql;
				}
				else {
					$params[] = $v;
					$set[] = $this->replace($k, false).'=?';
				}
			}
			$str = ' SET '.implode(', ', $set);

			$selectDal = clone $this;
			$selectDal->select('1')->from($this->getDefaultTable(true).' thisIsAUniqueAlias');

			$selectDal->replaceTable($this->getDefaultTable(), 'thisIsAUniqueAlias');

			foreach($this->db->getSchema()->table($this->getDefaultTable(true))->getColumns() as $colName=>$col)
				$selectDal->where('(thisIsAUniqueAlias.'.$colName.' IS NULL AND '.$this->getDefaultTable(true).'.'.$colName.' IS NULL OR thisIsAUniqueAlias.'.$colName.' = '.$this->getDefaultTable(true).'.'.$colName.')');

			$selectSql = $selectDal->buildSQL();

			$params = array_merge($params, $selectDal->getParameters());

			list($tables, $tableparams) = $this->buildTables(false);
			$params = array_merge($params, $tableparams);

			$sql = 'UPDATE '.$tables.$str."\n".'WHERE EXISTS ('.$selectSql.')';
		}
		else {
			$set = [];
			foreach($values as $k=>$v) {
				if($v instanceof static) {
					$sql = $v->buildSQL();
					$params = array_merge($params, $v->getParameters());
					$set[] = $this->replace($k, false).'=('.$sql.')';
				}
				elseif($v instanceof Raw) {
					$sql = $v->getSQL();
					$params = array_merge($params, $v->getParameters());
					$set[] = $this->replace($k, false).'='.$sql;
				}
				else {
					$params[] = $v;
					$set[] = $this->replace($k, false).'=?';
				}
			}
			$str = ' SET '.implode(', ', $set);

			list($tables, $tableparams) = $this->buildTables(false);
			$params = array_merge($params, $tableparams);

			list($where, $whereparams) = $this->buildWhere();
			$params = array_merge($params, $whereparams);

			$sql = 'UPDATE '.$tables.$str.$where;
		}

		$this->replaceArrayParams($sql, $params);
		$this->replaceRaws($sql, $params);

		$this->params = $params;

		return $sql;
	}
992070
public function update($fieldValues)
    {
        $r = 0;
        foreach ($this->queries as $query) {
            $t = $query->update($fieldValues);
            $r += $t;
        }

        return $r;
    }
505826
public function insert(array $values)
    {
        // get version values & values
        $versionValues = $this->getVersionValues($values);
        $values = $this->getValues($values);

        // set version, ref_id and latest_version
        $values[$this->model->getLatestVersionColumn()] = 1;

        // insert main table record
        if (! $id = $this->query->insertGetId($values)) {
            return false;
        }

        $versionValues[$this->model->getVersionKeyName()] = $id;
        $versionValues[$this->model->getVersionColumn()] = 1;

        // insert version table record
        $db = $this->model->getConnection();
        return $db->table($this->model->getVersionTable())->insert($versionValues);
    }
307524
public function update(array $values) {
		$sql = $this->buildUpdateSQL($values);
		$params = $this->getParameters();
		return $this->db->query($sql, $params)->affected();
	}
71781
public function saveRole(array $values): int
    {
        $result = $this->generalSave($values, $this->tableRole);
        $this->cache->clean([Cache::TAGS => ['DibiDriver']]);
        return $result;
    }
964831
public function update(array $data): int
    {
        $row = $this->queryRelate->getQuery()->update($data);

        $this->resetQueryRelate();

        return $row;
    }
481983
protected function addUpdatedAtColumn(array $values)
    {
        if (! $this->model->usesTimestamps() ||
            is_null($this->model->getUpdatedAtColumn())) {
            return $values;
        }

        $column = $this->model->getUpdatedAtColumn();

        $values = array_merge(
            [$column => $this->model->freshTimestampString()],
            $values
        );

        $values[$this->qualifyColumn($column)] = $values[$column];

        unset($values[$column]);

        return $values;
    }
1253117
public function prepareUpdate($table, array $values) {

        // Initialize the SET.
        $set = [];
        foreach ($values as $k => $v) {
            $set[] = "`" . $k . "` = " . $v;
        }

        // Initialize the query.
        $query = [];

        $query[] = "UPDATE ";
        $query[] = $table;
        $query[] = " SET ";
        $query[] = implode(", ", $set);

        // Return the query.
        return implode("", $query);
    }
1281655
public function insert(array $values)
	{
		// Since every insert gets treated like a batch insert, we will make sure the
		// bindings are structured in a way that is convenient for building these
		// inserts statements by verifying the elements are actually an array.
		if ( ! is_array(reset($values)))
		{
			$values = array($values);
		}

		// Since every insert gets treated like a batch insert, we will make sure the
		// bindings are structured in a way that is convenient for building these
		// inserts statements by verifying the elements are actually an array.
		else
		{
			foreach ($values as $key => $value)
			{
				ksort($value); $values[$key] = $value;
			}
		}

		// We'll treat every insert like a batch insert so we can easily insert each
		// of the records into the database consistently. This will make it much
		// easier on the grammars to just handle one type of record insertion.
		$bindings = array();

		foreach ($values as $record)
		{
			$bindings = array_merge($bindings, array_values($record));
		}

		$sql = $this->grammar->compileInsert($this, $values);

		// Once we have compiled the insert statement's SQL we can execute it on the
		// connection and return a result as a boolean success indicator as that
		// is the same type of result returned by the raw connection instance.
		$bindings = $this->cleanBindings($bindings);

		return $this->connection->insert($sql, $bindings);
	}