Simple OR WHERE condition with various set of arguments.

@param mixed ...$args [(column, value), (column, operator, value)]

@return self|$this

@throws BuilderException
@see AbstractWhere
511694
public function orWhere(...$args): self
    {
        $this->createToken('OR', $args, $this->whereTokens, $this->whereWrapper());

        return $this;
    }
933686
public function andWhere(...$args): self
    {
        $this->createToken('AND', $args, $this->whereTokens, $this->whereWrapper());

        return $this;
    }
878955
public function orHaving(...$args): self
    {
        $this->createToken('OR', $args, $this->havingTokens, $this->havingWrapper());

        return $this;
    }
683315
public function addQuery($args): self
    {
        if (!\is_array($args) && !($args instanceof AbstractQuery)) {
            throw new InvalidException('Invalid parameter. Has to be array or instance of Elastica\Query\AbstractQuery');
        }

        return $this->addParam('queries', $args);
    }
1252915
public function where($query, $queryParams = null, string $op = ''): self
    {
        if ($query == '') {
            throw new BuilderException('Query required!');
        }

        // sub-where
        if ($queryParams instanceof Builder) {
            // $opr argument is empty, should be exists in query (eg: id = )
            $query = $this->prepare($query, '', $queryParams);

            return $this->push('where', $query);
        }

        if (is_array($query)) {
            // eg: [['id' => ...], ...]
            foreach ($query as $field => $params) {
                // eg: ['id' => [1, '=', '?', 'or/and']], ['a.id' => [id('b.id'), ...]]
                if (is_array($params)) {
                    @ [$params, $operator, $escapeOperator, $op] = (array) $params;
                    if ($operator == null) {
                        $operator = '='; // @default=equal
                    }
                    $query = '?? '. $operator .' '. ($params instanceof Identifier ? '??' : $escapeOperator ?: '?');
                    $queryParams = [$field, $params];
                } else {
                    // eg: ['id' => 1]
                    $query = '?? = '. ($params instanceof Identifier ? '??' : '?');
                    $queryParams = [$field, $params];
                }

                $op = $op ? strtoupper($op) : self::OP_AND;
                if ($op != self::OP_OR && $op != self::OP_AND) {
                    throw new BuilderException('Available ops: OR, AND');
                }

                $query = $this->agent->prepare($query, $queryParams);

                $this->push('where', [[$query, $op]]);
            }

            return $this;
        }

        if (!is_string($query)) {
            throw new BuilderException(sprintf('String, array or Builder type queries are accepted only, %s given!',
                gettype($query)));
        }

        if ($queryParams !== null) {
            if (!is_array($queryParams) && !is_scalar($queryParams) && !($queryParams instanceof Identifier)) {
                throw new BuilderException(sprintf('Array, scalar and Query\Identifier params are accepted only, %s given!',
                    gettype($queryParams)));
            }
        }

        $query = $this->agent->prepare($query, $queryParams);

        $op = $op ? strtoupper($op) : self::OP_AND;
        if ($op != self::OP_OR && $op != self::OP_AND) {
            throw new BuilderException('Available ops: OR, AND');
        }

        return $this->push('where', [[$query, $op]]);
    }
34961
public function build(...$args)
    {
        $option = $this->query->getOption();
        $sql = 'select ' . $this->parseDistinct($option->distinct)
                . $this->parseField($option->field)
                . ' from '
                . $option->table
                . $this->parseJoin($option->join)
                . $this->parseWhere($option->where)
                . $this->parseGroup($option->group)
                . $this->parseHaving($option->having)
                . $this->parseOrder($option->order)
                . $this->parseLimit($option->offset, $option->limit)
                ;
        $this->query->bindValues($this->params);
        return $sql;
    }
809622
public function withArgs($args = [])
    {
        if (!is_array($args)) {
            $args = func_get_args();
        }

        $this->args = $args;
        return $this;
    }
293805
public function where($conditions)
    {
        if ($conditions = is_array($conditions) && func_num_args() === 1 ? $conditions : func_get_args()) {
            $this->_parts['where'][] = $conditions;
        }
        return $this;
    }
1127721
protected function isWhereNullByArgs(ArgumentBag $args)
    {
        return is_null($args->get('operator'))
            || is_null($args->get('value')) && !in_array($args->get('operator'), ['<>', '!=']);
    }
1022328
public function setArguments($arguments = array())
    {
        // add additional arguments
        if (!$arguments) {
            $arguments = array();
        }
        if (!is_array($arguments)) {
            throw new BaseException('Arguments must be always an array');
        }
        $this->arguments = $args = array_merge($this->arguments, $arguments);
        foreach ($args as $arg => $val) {
            if (is_null($val)) {
                unset($this->arguments[$arg]);
            }
        }

        return $this;
    }
389675
public function onWhere(...$args)
    {
        $this->createToken(
            'AND',
            $args,
            $this->joinTokens[$this->activeJoin]['on'],
            $this->onWhereWrapper()
        );

        return $this;
    }
821923
private function magicWhere($method, $args)
    {
        $whereStatement = explode('_', $method);

        // Get where
        if (count($whereStatement) == 2) {
            return $this->getWhere($args[0], '=', $args[1]);
        }

        $operators = [
            'in', 'between', 'like', 'null',
            'not',
            'first', 'last',
            'many',
        ];

        // If an operator is found then add operators.
        if (array_intersect($whereStatement, $operators)) {
            list($operator, $firstOrLast, $inverse) = $this->determineMagicWhereDetails($whereStatement);

            $column = $args[0];
            $value  = (isset($args[1]) ? $args[1] : null);

            return $this->getWhere(
                $column,
                $operator,
                $value,
                $inverse,
                $firstOrLast
            );
        }
    }
581629
public function orNotIn($column, $argument)
    {
        $this->conditions[] = 'OR ' . $this->grammar->buildId($column) . ' NOT IN(' . $argument . ')';

        return $this;
    }
234712
@SafeVarargs
  public final QueryBuilder arguments(Object...args) {
    set(Param.QUERY_ARGS, "");
    queryArgs = args.clone();
    return this;
  }
9029
public function setWhere(array $where)
    {
        // When the statement is empty set the
        // where property to null to prevent
        // empty statement errors.
        if (empty($where)) {
            // delete the current where statement
            $this->where = null;

            // Skip further execution
            return $this;
        }

        // Ensure the base $or clause
        if (! isset($where['$or'])) {
            // wrap the statement in an $or clause
            $where = ['$or' => [$where]];
        }

        // Fetch the last clause in the $or array
        // to allow further chaining it's required
        // to be wrapped in an @and statement.
        $lastClause = array_pop($where['$or']);

        if (! isset($lastClause['$and'])) {
            // Wrap in an @and statement
            $lastClause = ['$and' => [$lastClause]];
        }

        // Re-append the $and clause
        $where['$or'][] = $lastClause;

        // Replace the base where statement
        $this->where = $where;

        return $this;
    }
931497
public function where(Expr $where)
    {
        if ($where instanceof Parameter && $where == Expr::true()) {
            return $this;
        }

        if ($where instanceof BinOp && $where->getOperator() === BinOp::AND_) {
            $this->where($where->getLeft());
            $this->where($where->getRight());
        } else {
            $this->where[] = $where;
        }

        return $this;
    }
1191460
public function andWhere(...$conditions) : self
    {
        $this->conditionalQueryBuilder->andWhere(
            ...$this->createConditionExpressions($conditions)
        );

        return $this;
    }