Build where statement for SQL query

@param mixed $where
@param string $operand AND | OR
@return string
339881
function buildWhere($where, $operand = "AND")
    {
        if (empty($where)) {
            return "";
        }

        if (is_array($where)) {
            $wheres = array();
            foreach ($where as $k => $w) {
                $wheres[] = "(" . $w . ")";
            }
            $where = implode(" $operand ", $wheres);
        }

        return " WHERE " . $where;
    }
983998
public function whereRaw($where, $bind = [], $logic = 'AND')
    {
        if ($bind) {
            $this->bindParams($where, $bind);
        }

        $this->options['where'][$logic][] = $this->raw($where);

        return $this;
    }
825324
public function orWhere($field, $condition = false, $operator = '=')
    {
        if (func_num_args() >= 2) {
            $this->where->addOrCondition($field, $condition, $operator);
        } else {
            $this->where->addOrCondition($field);
        }

        return $this;
    }
1346248
private function assembleWhere($where = array())
    {
        if (is_array($where)) {
            switch ($where['operator']) {
                case Operator::$equals:
                    return $this->buildEquals($where['field'], $where['value']);
                case Operator::$doesNotEqual:
                    return $this->buildDoesNotEqual($where['field'], $where['value']);
                case Operator::$greaterThanOrEqual:
                    return $this->buildGreaterThanOrEquals($where['field'], $where['value']);
                case Operator::$lessThanOrEqual:
                    return $this->buildLessThanOrEquals($where['field'], $where['value']);
                case Operator::$approximateEqual:
                    return $this->buildApproximatelyEquals($where['field'], $where['value']);
                case Operator::$startsWith:
                    return $this->buildStartsWith($where['field'], $where['value']);
                case Operator::$endsWith:
                    return $this->buildEndsWith($where['field'], $where['value']);
                case Operator::$contains:
                    return $this->buildContains($where['field'], $where['value']);
                case Operator::$wildcard:
                    return $this->buildWildcard($where['field']);
            }
        }

        return;
    }
1178886
protected function whereSub(Builder $query, $where)
    {
        $select = $this->compileSelect($where['query']);

        return $this->wrap($where['column']).' '.$where['operator']." ($select)";
    }
224853
function where(column, operator, value) {

    // Support "where true || where false"
    if (column === false || column === true) {
      return this.where(1, '=', column ? 1 : 0);
    }

    // Check if the column is a function, in which case it's
    // a where statement wrapped in parens.
    if (typeof column === 'function') {
      return this.whereWrapped(column);
    }

    // Allow a raw statement to be passed along to the query.
    if (column instanceof Raw && arguments.length === 1) {
      return this.whereRaw(column);
    }

    // Allows `where({id: 2})` syntax.
    if (typeof column === 'object' && !(column instanceof Raw)) {
      return this._objectWhere(column);
    }

    // Enable the where('key', value) syntax, only when there
    // are explicitly two arguments passed, so it's not possible to
    // do where('key', '!=') and have that turn into where key != null
    if (arguments.length === 2) {
      value = operator;
      operator = '=';

      // If the value is null, and it's a two argument query,
      // we assume we're going for a `whereNull`.
      if (value === null) {
        return this.whereNull(column);
      }
    }

    // lower case the operator for comparison purposes
    var checkOperator = ('' + operator).toLowerCase().trim();

    // If there are 3 arguments, check whether 'in' is one of them.
    if (arguments.length === 3) {
      if (checkOperator === 'in' || checkOperator === 'not in') {
        return this._not(checkOperator === 'not in').whereIn(arguments[0], arguments[2]);
      }
      if (checkOperator === 'between' || checkOperator === 'not between') {
        return this._not(checkOperator === 'not between').whereBetween(arguments[0], arguments[2]);
      }
    }

    // If the value is still null, check whether they're meaning
    // where value is null
    if (value === null) {

      // Check for .where(key, 'is', null) or .where(key, 'is not', 'null');
      if (checkOperator === 'is' || checkOperator === 'is not') {
        return this._not(checkOperator === 'is not').whereNull(column);
      }
    }

    // Push onto the where statement stack.
    this._statements.push({
      grouping: 'where',
      type: 'whereBasic',
      column: column,
      operator: operator,
      value: value,
      not: this._not(),
      bool: this._bool()
    });
    return this;
  }
645144
public function addWhere(array $where)
    {
        if (count($where) !== 3) {
            throw new OrmException('Method "where" must have 3 parameters.');
        }

        $this->wheres[] = $where;

        $this->sql['where'] .= " ".$this->logicOperator." ".$this->addConditionsToSql()." ";

        $this->logicOperator = " AND ";
    }
972893
public function buildDSRetrievalSQL($data, &$joins, &$where, $andOperation = false)
    {
        $field_id = $this->get('id');

        if (preg_match('/^mimetype:/', $data[0])) {
            $data[0] = str_replace('mimetype:', '', $data[0]);
            $column = 'mimetype';
        } elseif (preg_match('/^size:/', $data[0])) {
            $data[0] = str_replace('size:', '', $data[0]);
            $column = 'size';
        } else {
            $column = 'file';
        }

        if (self::isFilterRegex($data[0])) {
            $this->buildRegexSQL($data[0], array($column), $joins, $where);
        } elseif (self::isFilterSQL($data[0])) {
            $this->buildFilterSQL($data[0], array($column), $joins, $where);
        } elseif ($andOperation) {
            foreach ($data as $value) {
                $this->_key++;
                $value = $this->cleanValue($value);
                $joins .= "
                    LEFT JOIN
                        `tbl_entries_data_{$field_id}` AS t{$field_id}_{$this->_key}
                        ON (e.id = t{$field_id}_{$this->_key}.entry_id)
                ";
                $where .= "
                    AND t{$field_id}_{$this->_key}.{$column} = '{$value}'
                ";
            }
        } else {
            if (!is_array($data)) {
                $data = array($data);
            }

            foreach ($data as &$value) {
                $value = $this->cleanValue($value);
            }

            $this->_key++;
            $data = implode("', '", $data);
            $joins .= "
                LEFT JOIN
                    `tbl_entries_data_{$field_id}` AS t{$field_id}_{$this->_key}
                    ON (e.id = t{$field_id}_{$this->_key}.entry_id)
            ";
            $where .= "
                AND t{$field_id}_{$this->_key}.{$column} IN ('{$data}')
            ";
        }

        return true;
    }
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;
    }
548122
public function buildAndCondition($operator, $operands)
    {
        $operator = $this->normalizeConditionKeyword($operator);
        $parts = [];
        foreach ($operands as $operand) {
            $parts[] = $this->buildCondition($operand);
        }

        return [$operator => $parts];
    }
456335
public function or_where()
	{
		$condition = func_get_args();
		is_array(reset($condition)) and $condition = reset($condition);

		return $this->_where($condition, 'or_where');
	}
1070798
public function buildDSRetrievalSQL($data, &$joins, &$where, $andOperation = false)
    {
        $field_id = $this->get('id');

        if (self::isFilterRegex($data[0])) {
            $this->buildRegexSQL($data[0], array('value'), $joins, $where);
        } elseif (self::isFilterSQL($data[0])) {
            $this->buildFilterSQL($data[0], array('value'), $joins, $where);
        } else {
            if (is_array($data)) {
                $data = $data[0];
            }

            $this->_key++;
            $data = $this->cleanValue($data);
            $joins .= "
                LEFT JOIN
                    `tbl_entries_data_{$field_id}` AS t{$field_id}_{$this->_key}
                    ON (e.id = t{$field_id}_{$this->_key}.entry_id)
            ";
            $where .= "
                AND MATCH (t{$field_id}_{$this->_key}.value) AGAINST ('{$data}' IN BOOLEAN MODE)
            ";
        }

        return true;
    }
74673
protected function whereRowValues(Builder $query, $where)
    {
        $columns = $this->columnize($where['columns']);

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

        return '('.$columns.') '.$where['operator'].' ('.$values.')';
    }
945815
public function whereRaw(string $raw, string $logicalOperator = LogicalOperator::AND)
    {
        $where = new Where();
        $where->useRaw();
        $where->setRawSQL($raw);
        $where->setLogicalOperator($logicalOperator);
        $this->option->where[] = $where;
        return $this;
    }
107668
public function or_where($wheres = array())
	{
		if (count($wheres) > 0)
		{
			if ( ! isset($this->wheres['$or']) or ! is_array($this->wheres['$or']))
			{
				$this->wheres['$or'] = array();
			}

			foreach ($wheres as $wh => $val)
			{
				$this->wheres['$or'][] = array($wh => $val);
			}
		}
		return $this;
	}
1339836
function queryFilter(where) {
  if (where.$or) {
    return object =>
      _.reduce(where.$or, (result, subclause) => result ||
        queryFilter(subclause)(object), false);
  }

  // Go through each key in where clause
  return object => _.reduce(where, (result, whereParams, key) => {
    const match = evaluateObject(object, whereParams, key);
    return result && match;
  }, true);
}
650735
public function where($query)
    {
        $clauses = $this->_where($query);

        $clause = implode(' AND ', $clauses);

        if (!empty($clause)) {
            $clause = 'WHERE '.$clause;
        }

        return $clause;
    }