Set the keys for a save update query.

@param Builder $query
@return Builder
359854
protected function setKeysForSaveQuery(Builder $query)
    {
        $query->where('group_id', $this->group_id)
              ->where('permission', $this->permission);

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

        return $query->where($this->relatedKey, $this->getAttribute($this->relatedKey));
    }
508785
public function update($query)
    {
        $resources = $query->getRepository()->getResources();

        foreach ($resources as $resource) {
            $names[] = $query->getPrefix().$resource->getName().' AS '.$this->_store->quoteName($resource->getAlias());
            //only join update if there are no order			
            if (!empty($query->order)) {
                break;
            }
        }

        $operation = $query->operation['value'];

        if (is_array($query->operation['value'])) {
            $operation = array();
            foreach ($query->operation['value'] as $key => $value) {
                $operation[] = is_numeric($key) ? $value : '@col('.$key.')='.$this->_store->quoteValue($value);
            }
            $operation = implode(',', $operation);
        }

        //only join update if there are no order
        if (empty($query->order)) {
            $resources = $query->getRepository()->getResources();

            foreach ($resources->getLinks() as $link) {
                $query->where($link->child, '=', $link->parent);
            }
        }

        $clause = 'UPDATE '.implode($names, ', ').' SET '.$operation;

        return $clause;
    }
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);
        }
    }
753889
public function compileSelect(Builder $query)
    {
        if (is_null($query->columns)) {
            $query->columns = ['*'];
        }

        $components = $this->compileComponents($query);

        // If an offset is present on the query, we will need to wrap the query in
        // a big "ANSI" offset syntax block. This is very nasty compared to the
        // other database systems but is necessary for implementing features.
        if ($this->isPaginationable($query, $components)) {
            return $this->compileAnsiOffset($query, $components);
        }

        return trim($this->concatenate($components));
    }
887594
protected function makeJoins(Builder $query)
    {
        foreach ($this->getJoins() as $table => $keys) {
            $query->leftJoin($table, function ($join) use ($keys) {
                $join->on($keys[0], '=', $keys[1]);
                if (array_key_exists(2, $keys) && array_key_exists(3, $keys)) {
                    $join->whereRaw($keys[2] . ' = "' . $keys[3] . '"');
                }
            });
        }
    }
289314
protected function exportableQuery(Builder $query): Builder
    {
        // Allow executing custom exportable query.
        if (method_exists($this->module, 'exportableQuery')) {
            return $this->module->exportableQuery($query);
        }

        return $query
            ->when($query->getModel() instanceof Translatable, function ($query) {
                $query->translated();
            })
            // leave select after joining with translations
            // table in order to rewrite selected columns
            ->select($this->exportableColumns());
    }
1052491
protected function setJoin(Builder $query = null)
    {
        $query = $query ?: $this->query;

        $foreignKey = $this->related->getTable().'.'.$this->secondKey;

        $query->join($this->parent->getTable(), $this->getQualifiedParentKeyName(), '=', $foreignKey);
    }
248967
protected function useWithTrashed(Builder $query)
    {
        if ($this->withTrashed && $query->getMacro('withTrashed') !== null) {
            return $query->withTrashed();
        }

        return $query;
    }
370209
protected function add_primary_keys_to_where($query)
	{
		$timestamp_start_name = static::temporal_property('start_column');
		$timestamp_end_name = static::temporal_property('end_column');

		$primary_key = array(
			'id',
			$timestamp_start_name,
			$timestamp_end_name,
		);

		foreach ($primary_key as $pk)
		{
			$query->where($pk, '=', $this->_original[$pk]);
		}
	}
612462
public function compileSelect(Builder $query)
    {
        if (is_null($query->columns)) $query->columns = array('*');

        return trim($this->concatenate($this->compileComponents($query)));
    }
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;
    }
836857
public function setQuery(\Illuminate\Database\Eloquent\Builder $query): GridInterface
    {
        $this->_query = $query;
        $this->_model = $this->_query->getModel();
        $this->pagination->setQuery($this->_query);

        return $this;
    }
486031
public function setQuery($query = null)
    {

        try {

            // need to return << true
            $this->validator->verify($query, ['isNotNull', 'isAcceptLength']);

            if (false === $this->exact) {
                $this->query = ['query' => '%' . $query . '%'];
            }
            else {
                $this->query = ['query' => $query];
            }

        }
        catch(ExceptionFactory $e) {
            echo $e->getMessage();
        }

        return $this;
    }
1097939
protected function buildInsertUpdateQueries(IInsertBuilder $query)
    {
        $values = $query->getValues();
        $whatSql = $this->quoteIdentifier($query->getTableName());
        $valuesSql = $this->buildValuesPart($values);

        $result = 'INSERT OR IGNORE INTO ' . $whatSql . $valuesSql . ";\n";

        $whereConditions = [];
        $columns = $query->getOnDuplicateKeyColumns();
        foreach ($values as $columnName => $placeholder) {
            if (in_array($columnName, $columns)) {
                $columnName = $this->quoteIdentifier($columnName);
                $placeholder = $this->protectExpressionValue($placeholder);
                $whereConditions[] = $columnName . ' = ' . $placeholder;
            }
        }
        $whereSql = "\nWHERE " . (count($whereConditions) ? implode(' AND ', $whereConditions) : '1');
        $setSql = $this->buildSetPart($query->getOnDuplicateKeyValues());
        $result .= 'UPDATE ' . $whatSql . $setSql . $whereSql . ';';

        return $result;
    }
625515
protected function setKeysForSaveQuery(Builder $query)
    {
        $query->where('tag_id', $this->tag_id)
              ->where('user_id', $this->user_id);

        return $query;
    }
309366
protected function replayMacros(Builder $query)
    {
        foreach ($this->macroBuffer as $macro) {
            $query->{$macro['method']}(...$macro['parameters']);
        }

        return $query;
    }