Creates where clause(s) from an array of conditions
@param array $conditions An array of conditions in the format:
<code>array("column" => $value)</code>
@param string $operator
@param string $condition
@return \Phiber\oosql\oosql Instance
490578
public function createWhere(array $conditions, $operator = '=', $condition = 'and')
    {

        foreach ($conditions as $col => $value) {

            if (null === $this->oosql_where) {
                $this->where($col . ' ' . $operator . '?', $value);
                continue;
            }

            $method = $condition . 'Where';

            $this->{$method}($col . ' ' . $operator . '?', $value);

        }

        return $this;
    }
1122035
private function build_conditions( $where, $columns, $glue = 'AND' ) {
		list ( $_where, $_where_format ) = $this->filter( $where, $columns );
		$conditions = $values = [];
		$index      = 0;
		foreach ( $_where as $field => $value ) {
			$field  = trim( $field );
			$format = $_where_format[ $index ++ ];
			if ( is_null( $value ) ) {
				$conditions[] = "$field IS NULL";
				continue;
			}

			if ( in_array( strtoupper( $field ), [
				'EXISTS',
				'NOT EXISTS',
			] ) ) {
				! is_array( $value ) and $value = [ $value ];
				foreach ( $value as $sub_query ) {
					$conditions[] = "$field ($sub_query)";
				}
				continue;
			}

			$op = '=';
			if ( is_array( $value ) ) {
				if ( count( $value ) > 1 ) {
					$op  = trim( $value[0] );
					$val = $value[1];
					if ( in_array( strtoupper( $op ), [
						'OR',
						'AND',
					] ) ) {
						array_shift( $value );
						$_conditions = [];
						foreach ( $value as $v ) {
							if ( ! is_array( $v ) ) {
								$_conditions[] = "1=0";
								continue;
							}
							list( $c, $v ) = $this->build_conditions( $v, $columns );
							$values        = array_merge( $values, $v );
							$_conditions[] = "({$c})";
						}
						$conditions[] = implode( " {$op} ", $_conditions );

						continue;
					}
					if ( is_array( $val ) ) {
						if ( empty( $val ) ) {
							$conditions[] = "1=0";
						} else {
							foreach ( $val as $v ) {
								$values[] = $v;
							}
							$conditions[] = "$field $op (" . str_repeat( $format . ',', count( $val ) - 1 ) . $format . ')';
						}
						continue;
					}
					if ( count( $value ) > 2 ) {
						$val          = $this->get_field_name( $val, $columns );
						$conditions[] = "$field $op $val";
						continue;
					}
				} else {
					$value        = reset( $value );
					$conditions[] = "$field ($value)";
					continue;
				}
			} else {
				$val = $value;
			}

			$conditions[] = "$field $op $format";
			$values[]     = $val;
		}
		$conditions = implode( " {$glue} ", $conditions );

		return [ $conditions, $values ];
	}
534068
public function where($field, $operator, $value = null)
    {
        if (func_num_args() === 2)
            $new = [$field, '=', $operator];
        else
            $new = func_get_args();

        $this->condition[0][] = $new;

        return $this;
    }
700719
protected function _operator($operator, $conditions, &$states)
    {
        if (isset($this->_operators[$operator])) {
            $config = $this->_operators[$operator];
        } elseif (substr($operator, -2) === '()') {
            $op = substr($operator, 0, -2);
            if (isset($this->_operators[$op])) {
                return '(' . $this->_operator($op, $conditions, $states) . ')';
            }
            $config = ['builder' => 'function'];
        } else {
            throw new SqlException("Unexisting operator `'{$operator}'`.");
        }
        $parts = $this->_conditions($conditions, $states);

        $operator = (is_array($parts) && next($parts) === 'NULL' && isset($config['null'])) ? $config['null'] : $operator;
        $operator = $operator[0] === ':' ? strtoupper(substr($operator, 1)) : $operator;

        if (isset($config['builder'])) {
            $builder = $this->_builders[$config['builder']];
            return $builder($operator, $parts);
        }
        if (isset($config['format'])) {
            return sprintf($config['format'], join(", ", $parts));
        }
        return join(" {$operator} ", $parts);
    }
1227395
public function where($column, $value, $operator = '=', $table = null)
    {
        $table = $table? $table : $this->table;
        $this->wheres[] = [
            'table' => $table,
            'column' => $column,
            'value' => $value,
            'operator' => $operator
        ];
        return $this;
    }
856935
public function filterCondition(array $data, $condition)
    {
        if (empty($condition)) {
            return $data;
        }

        if (!is_array($condition)) {
            throw new InvalidParamException('Condition must be an array');
        }

        if (isset($condition[0])) { // operator format: operator, operand 1, operand 2, ...
            $operator = strtoupper($condition[0]);
            if (isset($this->conditionFilters[$operator])) {
                $method = $this->conditionFilters[$operator];
            } else {
                $method = 'filterSimpleCondition';
            }

            array_shift($condition);

            return $this->$method($data, $operator, $condition);
        } else { // hash format: 'column1' => 'value1', 'column2' => 'value2', ...
            return $this->filterHashCondition($data, $condition);
        }
    }
11983
public function whereColumn($field1, $operator, $field2 = null, $logic = 'AND')
    {
        if (is_array($field1)) {
            foreach ($field1 as $item) {
                $this->whereColumn($item[0], $item[1], isset($item[2]) ? $item[2] : null);
            }
            return $this;
        }

        if (is_null($field2)) {
            $field2   = $operator;
            $operator = '=';
        }

        return $this->parseWhereExp($logic, $field1, 'COLUMN', [$operator, $field2], [], true);
    }
356662
public function addConditions(array $conditions = array())
    {
        foreach ($conditions as $key => $condition) {
            if (is_array($condition)) {
                call_user_func_array(array($this, 'addCondition'), $condition);
            } elseif (!$this->getBuilder()->getHelper()->isNumber($key)) {
                call_user_func_array(array($this, 'addCondition'), array($key, $condition));
            } else {
                $this->addCondition($condition);
            }
        }

        return $this;
    }
1290895
public function whereEmpty($conditions) {
		// if provided conditions are an array
		if(is_array($conditions)) {
			// for each condition
			foreach($conditions as $column) {
				// add the condition
				$this->whereEmpty($column);
			}
		}
		else {
			// secure the column name
			list(
				$column, 
				$placeholder
			) = Convert::columnToPlaceholder($this->Quote ,$conditions);
			// save the condition
			$this->Conditions[] = "{$this->Operator} ( {$column} == :empty_{$placeholder} OR {$column} IS NULL )";
			// add the empty value
			$this->Values[":empty_{$placeholder}"] = '';
		}
		// return self to the next method
		return $this;
	}
1213286
private function _where($operator, array $fields)
    {
        $count = count($fields);

        if ($count < 1 || $count > 3)
        {
            $fields = var_export($fields, true);
            throw new \InvalidArgumentException($fields);
        }

        $this->storageWhere[] = [$operator => $fields];

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

        return [$operator => $parts];
    }
465369
private function makeExpressions($conditions, $alias = self::DEFAULT_TABLE_ALIAS)
    {
        $expressions = [];
        foreach ($conditions as $attr) {
            $field = $attr['field'];
            if (strpos($field, '.') > 0) {
                //monta os joins
                $newAliasField = $this->associationQueryFields($field);
                $alias = $newAliasField['alias'];
                $field = $newAliasField['field'];
            }
            $expressions[] = $this->makeExpression($field, $attr['operation'], $attr['value'], $alias);
        }

        return $expressions;
    }
726543
private function buildWhere($condition, $operator, $value, $method)
    {
        $method = strtoupper($method);
        $QueryBuilder = $this->getQueryBuilder();

        if($operator && ! in_array($operator, array('=', '<', '>', '<>', '>=', '<=')))
        {
            throw new \Exception( 'El operador "'.$operator.'" en el metodo "where" no es valido.' );
        }

        if($operator !== null && $value !== null)
        {
            $field = str_replace('.', '', $condition);
            $condition = "{$condition}{$operator}:$field";

            $QueryBuilder->setParameter(":$field", $value);
        }

        if($method == 'WHERE')
        {
            // Verifica que si existe un where para agregar un "AND WHERE"
            if(count($QueryBuilder->getQueryPart('where')) > 0)
            {
                $QueryBuilder->andWhere($condition);
            }
            else
            {
                $QueryBuilder->where($condition);
            }
        }
        else if($method == 'AND_WHERE')
        {
            $QueryBuilder->andWhere($condition);
        }
        else if($method == 'OR_WHERE')
        {
            $QueryBuilder->orWhere($condition);
        }
    }
952615
public function where($column, $operator = null, $value = null, $boolean = 'and') {
        // If the column is an array, we will assume it is an array of key-value pairs
        // and can add them each as a where clause. We will maintain the boolean we
        // received when the method was called and pass it into the nested where.
        if (is_array($column)) {
            return $this->whereNested(function ($query) use ($column) {
                        foreach ($column as $key => $value) {
                            $query->where($key, '=', $value);
                        }
                    }, $boolean);
        }

        // Here we will make some assumptions about the operator. If only 2 values are
        // passed to the method, we will assume that the operator is an equals sign
        // and keep going. Otherwise, we'll require the operator to be passed in.
        if (func_num_args() == 2) {
            list($value, $operator) = [$operator, '='];
        } elseif ($this->invalidOperatorAndValue($operator, $value)) {
            throw new InvalidArgumentException('Illegal operator and value combination.');
        }

        // If the columns is actually a Closure instance, we will assume the developer
        // wants to begin a nested where statement which is wrapped in parenthesis.
        // We'll add that Closure to the query then return back out immediately.
        if ($column instanceof Closure) {
            return $this->whereNested($column, $boolean);
        }

        // If the given operator is not found in the list of valid operators we will
        // assume that the developer is just short-cutting the '=' operators and
        // we will set the operators to '=' and set the values appropriately.
        if (!in_array(strtolower($operator), $this->operators, true)) {
            list($value, $operator) = [$operator, '='];
        }

        // If the value is a Closure, it means the developer is performing an entire
        // sub-select within the query and we will need to compile the sub-select
        // within the where clause to get the appropriate query record results.
        if ($value instanceof Closure) {
            return $this->whereSub($column, $operator, $value, $boolean);
        }

        // If the value is "null", we will just assume the developer wants to add a
        // where null clause to the query. So, we will allow a short-cut here to
        // that method for convenience so the developer doesn't have to check.
        if (is_null($value)) {
            return $this->whereNull($column, $boolean, $operator != '=');
        }

        // Now that we are working with just a simple query we can put the elements
        // in our array and add the query binding to our array of bindings that
        // will be bound to each SQL statements when it is finally executed.
        $type = 'Basic';

        $this->wheres[] = compact('type', 'column', 'operator', 'value', 'boolean');

        if (!$value instanceof Expression) {
            $this->addBinding($value, 'where');
        }

        return $this;
    }
394097
public function addWhere($where, $params = [], $operator = 'AND')
    {
        if ($where instanceof Criteria) {
            return $this->addCriteria($where);
        }
        if (null === $where) {
            return $this;
        }
        if (isset($this->query['where']) && !empty($this->query['where'])) {
            $operator = strtoupper($operator);
            $where = "({$this->query['where']}) {$operator} ({$where})";
        }
        $this->query['where'] = $where;
        $this->addParams($params);
        return $this;
    }
274005
public function orWhere(...$conditions) : self
    {
        $this->conditionalQueryBuilder->orWhere(
            ...$this->createConditionExpressions($conditions)
        );

        return $this;
    }