Update model with binary (blob) fields.

@param Builder $query
@param array $dirty
542903
protected function updateBinary(Builder $query, $dirty)
    {
        $builder = $this->setKeysForSaveQuery($query);

        if ($this->extractBinaries($dirty)) {
            $builder->updateLob($dirty, $this->binaryFields, $this->getKeyName());
        } else {
            $builder->update($dirty);
        }
    }
244245
protected function insertAndSetId(BaseBuilder $query, $attributes)
	{
		// This allows values that are set by Kinvey, and returned in the
		// inserted model ('_kmd', '_acl' etc.) to be immediately added
		// to the new model instance.

		$result = $query->insert($attributes);

		$this->setRawAttributes(reset($result));
	}
1114054
protected function setKeysForSaveQuery(Builder $query)
    {
        foreach ($this->getKeyName() as $key) {
            if (isset($this->$key))
                $query->where($key, '=', $this->$key);
            else
                throw new Exception(__METHOD__ . 'Missing part of the primary key: ' . $key);
        }

        return $query;
    }
926603
protected function updateRecord(Query $query): bool
	{
		$query->where($this->primaryKey, '=', $this->columns[$this->primaryKey]);

		return (bool) $query->update($this->getModified());
	}
464101
public function compileUpdate(Builder $query, $values)
    {
        $table = $this->wrapTable($query->from);

        // Each one of the columns in the update statements needs to be wrapped in the
        // keyword identifiers, also a place-holder needs to be created for each of
        // the values in the list of bindings so we can make the sets statements.
        $columns = $this->compileUpdateColumns($query, $values);

        $from = $this->compileUpdateFrom($query);

        $where = $this->compileUpdateWheres($query);

        return trim("update {$table} set {$columns}{$from} {$where}");
    }
1282439
public function mergeBindings(Builder $query)
	{
		$this->bindings = array_values(array_merge($this->bindings, $query->bindings));

		return $this;
	}
571631
protected function compileUpdateFrom(Builder $query)
    {
        if (! isset($query->joins)) {
            return '';
        }

        // When using Postgres, updates with joins list the joined tables in the from
        // clause, which is different than other systems like MySQL. Here, we will
        // compile out the tables that are joined and add them to a from clause.
        $froms = collect($query->joins)->map(function ($join) {
            return $this->wrapTable($join->table);
        })->all();

        if (count($froms) > 0) {
            return ' from '.implode(', ', $froms);
        }
    }
932773
function UpdateBlob($table,$column,$val,$where,$blobtype='BLOB')
	{
		return $this->Execute("UPDATE $table SET $column=? WHERE $where",array($val)) != false;
	}
373389
public function apply(Builder $query, $or = false)
    {
        $field_alias = $this->field_alias;

        if($or)
        {
            $query->orWhereBetween($field_alias, [$this->value_min, $this->value_max]);
        }
        else
        {
            $query->whereBetween($field_alias, [$this->value_min, $this->value_max]);
        }
    }
774601
protected function setKeysForSaveQuery(Builder $query)
	{
		$query->where($this->morphType, $this->getAttribute($this->morphType));

		return parent::setKeysForSaveQuery($query);
	}
173241
public function compileInsert(Builder $query, array $values)
	{
		// Essentially we will force every insert to be treated as a batch insert which
		// simply makes creating the SQL easier for us since we can utilize the same
		// basic routine regardless of an amount of records given to us to insert.
		$table = $this->wrapTable($query->from);

		if ( ! is_array(reset($values)))
		{
			$values = array($values);
		}

		// If there is only one record being inserted, we will just use the usual query
		// grammar insert builder because no special syntax is needed for the single
		// row inserts in SQLite. However, if there are multiples, we'll continue.
		if (count($values) == 1)
		{
			return parent::compileInsert($query, reset($values));
		}

		$names = $this->columnize(array_keys(reset($values)));

		$columns = array();

		// SQLite requires us to build the multi-row insert as a listing of select with
		// unions joining them together. So we'll build out this list of columns and
		// then join them all together with select unions to complete the queries.
		foreach (array_keys(reset($values)) as $column)
		{
			$columns[] = '? as '.$this->wrap($column);
		}

		$columns = array_fill(0, count($values), implode(', ', $columns));

		return "insert into $table ($names) select ".implode(' union select ', $columns);
	}
597757
public function apply(Builder $query)
    {
        if($this->skip !== null)
        {
            $query->skip($this->skip);
        }

        if($this->take !== null)
        {
            $query->take($this->take);
        }
    }
625515
protected function setKeysForSaveQuery(Builder $query)
    {
        $query->where('tag_id', $this->tag_id)
              ->where('user_id', $this->user_id);

        return $query;
    }
1225363
protected function compileUpdateFrom(Builder $query)
	{
		if ( ! isset($query->joins)) return '';

		$froms = array();

		// When using Postgres, updates with joins list the joined tables in the from
		// clause, which is different than other systems like MySQL. Here, we will
		// compile out the tables that are joined and add them to a from clause.
		foreach ($query->joins as $join)
		{
			$froms[] = $this->wrapTable($join->table);
		}

		if (count($froms) > 0) return ' from '.implode(', ', $froms);
	}
161405
protected function prefixAndMerge(Builder $query, $prefix)
    {
        $this->prefixWheres($query, $prefix);
        $this->query->mergeWheres($query->getQuery()->wheres, $query->getQuery()->getBindings());
    }
676034
protected function setUuidKeysForSaveQuery(Builder $query)
    {
        $query->where($this->getUuidKeyName(), '=', $this->getUuidKeyForSaveQuery());

        return $query;
    }
55463
protected function setKeysForSaveQuery(Builder $query)
    {
        $query->where($this->foreignKey, $this->getAttribute($this->foreignKey));

        return $query->where($this->otherKey, $this->getAttribute($this->otherKey));
    }