Builds a where condition from the array parameter.

Example
$condition = [
['=', 'id', '1'],
['and'],
['!=', 'status', '0']
];

@param array $condition is an array

@return string $where
168809
private function buildCondition($condition) 
    {
        $where = '';
        
        foreach($condition as $filter) {
            switch(count($filter)) {
                case 1:
                $where .= ' ' . $this->validateLogicalOperator(($filter[0])) . ' ';
                break;
                case 3:
                $where .= $this->quoteColumnName($filter[1]) .' '. $this->validateComparisonOperators($filter[0]) .' '. $this->handleThridParameter($filter[2]);
                break;
                case 4:
                $where .= $this->quoteColumnName($filter[1]) .' '. $this->validateComparisonOperators($filter[0]) .' '. $this->quoteValue($filter[2]) . ' AND ' . $this->quoteValue($filter[3]);
                break;
            }
        }
        
        return $where;
    }
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;
    }
404598
public function clause($condition = 'AND')
    {
        if (empty($this->where)) {
            $condition = null;
        }
        $clause = new AnDomainQueryClause($this, $condition);

        return $clause;
    }
293805
public function where($conditions)
    {
        if ($conditions = is_array($conditions) && func_num_args() === 1 ? $conditions : func_get_args()) {
            $this->_parts['where'][] = $conditions;
        }
        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);
        }
    }
690831
public function seek($condition = array(), $order=array()){
		$where = array();
		$orderBy = array();
		foreach ($condition as $key=>$value){
			if ($value!=NULL && is_object($value) && get_class($value)==NotSet::class){
				// nuevo. el campo no está establecido
			}else{
				$where[] = sprintf("`%s` = %s", $key, $this->getColumn($key)->sqlVal($value));
			}
		}
		foreach ($order as $key=>$value){
			$orderBy[] = sprintf("`%s` %s", $key, $value);
		}
		if (count($where)>0){
			$sWhere = " WHERE ".implode(' and ', $where);
		}else{
			$sWhere = "";
		}
		if (count($orderBy)>0){
			$sOrder = " ORDER BY ".implode(',', $orderBy);
		}else{
			$sOrder = "";
		}
		$sSql = sprintf("SELECT * FROM `%s` %s %s LIMIT 0,1", $this->getTableName(), $sWhere, $sOrder);
		$rows = $this->model->getRecords($sSql);
		if (count($rows)>0){
			return $this->fromRowToModelRow($rows[0]);
		}else{
			//return NULL;
			throw new \Exception("Registro no localizado");
		}
	}
1356885
public function where($conditions, $params = array())
    {
        $this->mergeParams($params);
        $this->query['where'] = $this->buildConditions($conditions);

        return $this;
    }
1346529
public function where($key, $condition)
    {
        $this->conditions[$key] = self::$conditionRegex[$condition];
        return $this;
    }
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;
    }
857495
public function findOne(Condition $condition)
    {
        $result = null;
        $row = $this->microDb->getCollection($this->collectionName)->fetchOne(
            $this->conditionParser->filter($condition),
            $this->conditionParser->sort($condition)
        );
        if ($row) {
            /** @var AbstractEntity $result */
            $result = $this->factory->create();
            $result->mapFromArray($row);
        }

        return $result;
    }
612789
public function addCondition(Condition $condition): Condition
    {
        $query = $this->connection->createQueryBuilder()
            ->insert('ngbm_rule_condition')
            ->values(
                [
                    'id' => ':id',
                    'status' => ':status',
                    'rule_id' => ':rule_id',
                    'type' => ':type',
                    'value' => ':value',
                ]
            )
            ->setValue(
                'id',
                $condition->id !== null ?
                    (int) $condition->id :
                    $this->connectionHelper->getAutoIncrementValue('ngbm_rule_condition')
            )
            ->setParameter('status', $condition->status, Type::INTEGER)
            ->setParameter('rule_id', $condition->ruleId, Type::INTEGER)
            ->setParameter('type', $condition->type, Type::STRING)
            ->setParameter('value', json_encode($condition->value), Type::STRING);

        $query->execute();

        $condition->id = $condition->id ?? (int) $this->connectionHelper->lastInsertId('ngbm_rule_condition');

        return $condition;
    }
924198
public function product(array $condition, array $data)
    {
        $is_product = (int) isset($data['product_id']);
        $value = (int) filter_var(reset($condition['value']), FILTER_VALIDATE_BOOLEAN);
        return $this->compare($is_product, $value, $condition['operator']);
    }
979377
public function filterOne(array $condition)
	{
		foreach ($this->data as $item) {
			foreach ($condition as $key => $value) {
				if ($item[$key] == $value) {
					$this->setData([$item]);

					return $this;
				}
			}
		}

		$this->setData([]);

		return $this;
	}
302295
public function where($conditions, ...$parameters)
    {
        if (is_array($conditions)) {
            $this->where = array_merge($this->where, array_map(function ($value, $field) {
                $field = $this->connection->quoteIdentifier($field);
                if ($value === null) {
                    return $field . ' IS NULL';
                }

                return $field . '=' . $this->connection->quote($value);
            }, $conditions, array_keys($conditions)));
        } else {
            if ($parameters) {
                $conditions = $this->connection->merge($conditions, $parameters);
            }
            $this->where[] = $conditions;
        }

        return $this;
    }
305772
public function buildHashCondition($condition)
    {
        $result = [];
        foreach ($condition as $name => $value) {
            if (strncmp('$', $name, 1) === 0) {
                // Native Mongo condition:
                $result[$name] = $value;
            } else {
                if (is_array($value)) {
                    if (ArrayHelper::isIndexed($value)) {
                        // Quick IN condition:
                        $result = array_merge($result, $this->buildInCondition('IN', [$name, $value]));
                    } else {
                        // Mongo complex condition:
                        $result[$name] = $value;
                    }
                } else {
                    // Direct match:
                    if ($name == '_id') {
                        $value = $this->ensureMongoId($value);
                    }
                    $result[$name] = $value;
                }
            }
        }

        return $result;
    }
784327
private function makeArrayQueryIn(Builder $query, stdClass $rule, $operator, array $value, $condition)
    {
        if ($operator == 'NOT IN') {
            return $query->whereNotIn($rule->field, $value, $condition);
        }

        return $query->whereIn($rule->field, $value, $condition);
    }
811522
public function setCondition(array $condition)
    {
        if (!isset($condition['function'])) {
            return false;
        }

        $this->conditional_function = $condition['function'];

        if (isset($condition['parameters'])) {
            $this->conditional_parameters = (array) $condition['parameters'];
        }

        if (isset($condition['inverse'])) {
            $this->conditional_inverse = (boolean) $condition['inverse'];
        }
    }