yii\mongodb\QueryBuilder::buildCondition PHP Méthode

buildCondition() public méthode

Parses the condition specification and generates the corresponding Mongo condition.
public buildCondition ( array $condition ) : array
$condition array the condition specification. Please refer to [[Query::where()]] on how to specify a condition.
Résultat array the generated Mongo condition
    public function buildCondition($condition)
    {
        static $builders = ['NOT' => 'buildNotCondition', 'AND' => 'buildAndCondition', 'OR' => 'buildOrCondition', 'BETWEEN' => 'buildBetweenCondition', 'NOT BETWEEN' => 'buildBetweenCondition', 'IN' => 'buildInCondition', 'NOT IN' => 'buildInCondition', 'REGEX' => 'buildRegexCondition', 'LIKE' => 'buildLikeCondition'];
        if (!is_array($condition)) {
            throw new InvalidParamException('Condition should be an array.');
        } elseif (empty($condition)) {
            return [];
        }
        if (isset($condition[0])) {
            // operator format: operator, operand 1, operand 2, ...
            $operator = strtoupper($condition[0]);
            if (isset($builders[$operator])) {
                $method = $builders[$operator];
            } else {
                $operator = $condition[0];
                $method = 'buildSimpleCondition';
            }
            array_shift($condition);
            return $this->{$method}($operator, $condition);
        } else {
            // hash format: 'column1' => 'value1', 'column2' => 'value2', ...
            return $this->buildHashCondition($condition);
        }
    }