Sets the WHERE param to the query.

@param int|array    $where WHERE param.
@param QueryBuilder $query Query to build.
@param string       $primaryKey Table primary key.

@return QueryBuilder Query object.
458
private static function _setWhere($where, QueryBuilder $query, string $primaryKey = "id") : QueryBuilder
    {
        if(!is_array($where)) {
            return $query->where([
                $primaryKey => $where
            ]);
        }

        $columns = $where;

        unset($columns["ORDER BY"]);
        unset($columns["LIMIT"]);
        unset($columns["OFFSET"]);

        if(!empty($columns)) {
            $query->where($columns);
        }

        if(isset($where["ORDER BY"])) {
            $order = $where["ORDER BY"];
            if(!is_array($order)) {
                $order = [$order];
            }

            $query->order(... $order);
        }
        if(isset($where["LIMIT"])) {
            $limit = $where["LIMIT"];
            if(!is_array($limit)) {
                $limit = [$limit];
            }

            $query->limit(... $limit);
        }
        if(isset($where["OFFSET"])) {
            $query->offset($where["OFFSET"]);
        }

        return $query;
    }
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;
        }
    }
1173087
private void setWhere(Where where) throws SqlParseException {
        if (where != null) {
            QueryBuilder whereQuery = QueryMaker.explan(where,this.select.isQuery);
            request.setQuery(whereQuery);
        }
    }
622791
protected function whereSubquery(array $where)
    {
        return $this->wrap($where['column']) . ' ' . $where['operator'] . ' (' . $this->select($where['subquery']->getSQLStatement()) . ')';
    }
172547
public function del($id, $where=null)
	{
        if ($where == null)
        {
            $where = $this->primary;
        }
        return $this->db->delete($id, $this->table, $where);
	}
32007
public function orWhere(string $key, string $operator, $value): QueryBuilder
    {
        $this->addWhere($key, $operator, $value, 'OR');
        return $this;
    }
566619
public function extractPrimaryKey($where) {
        if (is_array($where)) {
            $where = implode(' AND ', $where);
        }
        $pkColumns = $this->info(Zend_Db_Table_Abstract::PRIMARY);
        $pkValues = array();
        foreach ($pkColumns as $pk) {
            $regexp = '/(?:`?' . preg_quote($this->getName()) . '`?\.)?`?(?:' . preg_quote($pk) .
                ')`?\s?=\s?(?:(?P<q>[\'"])(?P<value>(?:(?!\k<q>).)*)\k<q>|(?P<rest>\w*))/';
            if (preg_match($regexp, $where, $matches)) {
                // Note: backreference "rest" is there to catch unquoted
                // values. (id = 100 instead of id = "100")
                if (!empty($matches['rest'])) {
                    $value = $matches['rest'];
                } else {
                    $value = $matches['value'];
                }
                $pkValues[$pk] = $value;
            }
        }
        return $pkValues;
    }
1291070
protected function compileWheres(Builder $query)
    {
        $wheres = [];

        $hasWheres = !is_null($query->wheres);

        if ($hasWheres) {
            foreach ($query->wheres as $where) {
                if ($this->hasReplacedParameter($where)) {
                    continue;
                }

                $wheres[$where['column']] = $where['value'];
            }

            // Here we create the query string. Some APIs (Graphite) support multiple
            // parameters with the same key. When we find an entry with multiple values
            // well add it multiple times to the query.
            if (count($wheres) > 0) {
                $queryString = null;

                foreach ($wheres as $key => $value) {
                    if (is_array($value)) {
                        foreach ($value as $attribute) {
                            $queryString .= $this->buildQuery($key, $attribute);
                        }
                    } else {
                        $queryString .= $this->buildQuery($key, $value);
                    }
                }

                return substr($queryString, 1, strlen($queryString));
            }
        }

        return '';
    }
344128
public function where($where, $regex_constraint = null)
    {
        if (is_array($where)) {
            $other_rule = $where;
        } else {
            $other_rule = [$where => $regex_constraint];
        }

        $this->with = array_merge($this->with, $other_rule);

        return $this;
    }
617691
protected function dateBasedWhere($type, Builder $query, $where)
    {
        $value = $this->parameter($where['value']);

        return 'extract('.$type.' from '.$this->wrap($where['column']).') '.$where['operator'].' '.$value;
    }
403559
protected function whereNotIn(Builder $query, $where)
    {
        if (empty($where['values'])) {
            return '1 = 1';
        }

        $values = $this->parameterize($where['values']);

        return $this->wrap($where['column']).' not in ('.$values.')';
    }
643323
protected function setUpdateCriteria(
        Sql\SqlInterface $query, $primaryKey, $table
    ) {
        $key = "{$table}.{$primaryKey} = :id";
        $query->where([$key => [':id' => $this->entity->{$primaryKey}]]);
        return $query;
    }
152773
public function query($query,$sqlParams=null)
    {
        $this->query =  (string)$query;
        if ($sqlParams!=null) {
            $this->sqlParams = $sqlParams;
        }
        return $this;
    }
736046
protected function setKeysForSaveQuery(Builder $query)
    {
        if (count($this->primaryKey)) {
            foreach ($this->primaryKey as $key) {
                if (isset($this->original[$key])) {
                    $value = $this->original[$key];
                } else {
                    $value = $this->getAttribute($key);
                }
                $query->where($key, $value);
            }
        } else {
            $query->where($this->getKeyName(), '=', $this->getKeyForSaveQuery());
        }

        return $query;
    }
635283
public function buildQuery(string $table, array $set, array $where): SqlParams
    {
        if (empty($set) || empty($where)) {
            throw new \Exception('Set and where arrays cannot be empty');
        }

        $params = [];
        $sql = "UPDATE {$table} SET ";

        foreach ($set as $column => $value) {
            $sql .= $this->options->escapeIdentifier($column) . ' = ?, ';
            $params[] = $value;
        }

        $sql = substr_replace($sql, '', -2); // remove trailing comma
        $whereClause = $this->buildWhereClause($where);
        $sql .= $whereClause->getSql();

        return new SqlParams($sql, array_merge($params, $whereClause->getParams()));
    }
1026263
protected function whereJsonBoolean(Builder $query, $where)
    {
        $column = $this->wrapJsonBooleanSelector($where['column']);

        $value = $this->wrapJsonBooleanValue(
            $this->parameter($where['value'])
        );

        return $column.' '.$where['operator'].' '.$value;
    }
353579
private void setWhere(Where where) throws SqlParseException {
		if (where != null) {
			BoolQueryBuilder boolQuery = QueryMaker.explan(where,this.select.isQuery);
			request.setQuery(boolQuery);
		}
	}