Adds an Sql exists expression to the $this->_Wheres collection.
@param Gdn_DatabaseDriver $SqlDriver The sql to add.
@param string $Op Either 'exists' or 'not exists'
@return Gdn_DatabaseDriver $this
193260
public function WhereExists($SqlDriver, $Op = 'exists') {
      $Sql = $Op . " (\r\n" . $SqlDriver->GetSelect() . "\n)";
      
      // Add the inner select.
      $this->_Where($Sql);
      
      // Add the named parameters from the inner select to this statement.
      foreach($SqlDriver->_NamedParameters as $Name => $Value) {
         $this->_NamedParameters[$Name] = $Value;
      }
      
      return $this;
   }
253128
public function whereId(string $field, $id, string $op = ''): self
    {
        return $this->where('?? = ?', [$field, $id], $op);
    }
1209847
public function andWhere($field, $operation, $value = null, $alias = self::DEFAULT_TABLE_ALIAS)
    {
        if (strpos($field, '.') > 0) {
            //monta os joins
            $this->fieldValue = [
                'value'     => $value,
                'operation' => $operation,
            ];
            $newAliasField = $this->associationQueryFields($field);
            $alias = $newAliasField['alias'];
            $field = $newAliasField['field'];
        }
        $this->queryBuilder->andWhere($this->makeExpression($field, $operation, $value, $alias));

        return $this;
    }
926267
public function and(string $field, string $operator, string $field2)
    {
        $this->addClause(
            'where',
            compact('field', 'operator', 'field2')
        );

        return $this;
    }
781130
private function addRelation(string $logic, $column1, ?string $operator, $column2)
    {
        $column1 = $this->prepareRow($column1);

        $column2 = $this->prepareRow($column2);

        if (is_array($column1)) {
            $this->addRowRelation($logic, $column1, $operator, (array) $column2);

            return $this;
        }

        if (!$operator) {
            $operator = is_array($column2) ? 'IN' : '=';
        }

        if ($operator === 'IN' and !is_array($column2)) {
            $operator = '=';
        }

        if ($operator !== 'IN' and is_array($column2)) {
            throw new SqlException('Second column could not be an array in relation for operator `' . $operator . '`.');
        }

        $column2 = is_array($column2) ? $this->prepareColumns($column2) : $this->dialect()->quoteName($column2);

        $sql = $this->dialect()->quoteName($column1) . ' ' . $operator . ' ' . $column2;

        $this->addCondition($logic, $sql);

        return $this;
    }
902478
public function or_where($column, $op = null, $value = null)
	{
		if($column instanceof \Closure)
		{
			$this->or_where_open();
			$column($this);
			$this->or_where_close();
			return $this;
		}

		if (is_array($column))
		{
			foreach ($column as $key => $val)
			{
				if (is_array($val))
				{
					$this->or_where($val[0], $val[1], $val[2]);
				}
				else
				{
					$this->or_where($key, '=', $val);
				}
			}
		}
		else
		{
			if(func_num_args() === 2)
			{
				$value = $op;
				$op = '=';
			}
			$this->_where[] = array('OR' => array($column, $op, $value));
		}
		return $this;
	}
1174960
public function where($field, $operator = null, $value = null, $boolean = 'AND')
    {
        // If the developer is adding multiple where statements together,
        // we will enforce that by adding the approriate boolean.

        if ($this->condition && count($this->condition) > 0) {
            $this->condition[] = $boolean;
        }

        // Here we will make some assumptions about the operator. If only two values
        // are passed in, we will assume the operator is an equals sign. Furthermore,
        // we will identify if the value is null and apply the respective operator.

        list($value, $operator) = $this->prepareValueAndOperator(
            $value, $operator, func_num_args() == 2
        );

        $this->condition[] = [
            'field' => compact('field'),
            'op' => $operator,
            'value' => $value
        ];

        return $this;
    }
664725
public function whereCmp($field, $operator, $value)
    {
        foreach ($this->queries as $query) {
            $query->whereCmp($field, $operator, $value);
        }

        return $this;
    }
665148
private function addOnToSql()
    {
        $paramsOn = '';

        foreach ($this->ons as $on) {
            $comporaisonOperator = $on[1];
            if (!in_array($comporaisonOperator, self::COMPARAISON_OPERATORS)) {
                throw new OrmException('Comparaison operator "'.$comporaisonOperator.'" not allowed.');
            }

            $paramsOn .= $on[0]." ".$comporaisonOperator." ".$on[2]." ";
        }

        $this->ons = [];

        return $paramsOn;
    }
1288412
function where($left, $operator = Query::EQUAL, $right = null, $quote = null) {
		if (func_num_args() === 1) {
			return $this->addAnd($left);
		}
		return $this->addAnd($left, $right, $operator, $quote);
	}
114499
public function whereInfix($field, $operator = '=', $condition = false)
    {
        $numArgs = func_num_args();
        if ($numArgs > 2) {
            $this->where->addCondition($field, $condition, $operator);
        } elseif ($numArgs == 2) {
            $this->where->addCondition($field, $operator, '=');
        } else {
            $this->where->addCondition($field);
        }

        return $this;
    }
1181328
public function where($field, $operator = null, $value = null)
    {
        return $this->andWhere($field, $operator, $value);
    }
1236837
public function orderBy($field, string $op = null): self
    {
        // check operator is valid
        if ($op == null) {
            return $this->push('orderBy', $this->prepareField($field));
        }

        $op = strtoupper($op);
        if ($op != self::OP_ASC && $op != self::OP_DESC) {
            throw new BuilderException('Available ops: ASC, DESC');
        }

        return $this->push('orderBy', $this->prepareField($field) .' '. $op);
    }
1131065
public function where($operand, $operatorOrValue=null, $value=null)
    {
        return $this->addWhere($operand, $operatorOrValue, $value, 'and', func_num_args());
    }
438411
public final function where($where = null, array $whereParams = null, string $op = null): ?string
    {
        if ($where != null) {
            $whereType = gettype($where);
            if ($whereType == 'array') {
                $op = strtoupper($op ?: 'AND');
                if (!in_array($op, ['AND', 'OR'])) {
                    throw new AgentException("Invalid operator '{$op}' given");
                }
                $where = join(' '. $op .' ', $where);
            } elseif ($whereType != 'string') {
                throw new AgentException("Invalid where type '{$whereType}' given");
            }

            $where = ($whereParams != null) ? 'WHERE ('. $this->prepare($where, $whereParams) .')'
                : 'WHERE ('. $where .')';

        }

        return $where;
    }
930337
public function orWhere($field, $op, $value)
    {
        $this->pending['where'][] = array(
            'type'  => 'or',
            'field' => $field,
            'op'    => $op,
            'value' => $value,
        );

        return $this;
    }
742310
public function whereExists(SelectQuery $sql)
    {
        $this->wConditions = null;

        $this->exists = [
            'sql'    => $sql,
            'negate' => false,
        ];

        return $this;
    }