yii\db\QueryBuilder::buildCondition PHP Method

buildCondition() public method

Parses the condition specification and generates the corresponding SQL expression.
public buildCondition ( string | array | yii\db\Expression $condition, array &$params ) : string
$condition string | array | yii\db\Expression the condition specification. Please refer to [[Query::where()]] on how to specify a condition.
$params array the binding parameters to be populated
return string the generated SQL expression
    public function buildCondition($condition, &$params)
    {
        if ($condition instanceof Expression) {
            foreach ($condition->params as $n => $v) {
                $params[$n] = $v;
            }
            return $condition->expression;
        } elseif (!is_array($condition)) {
            return (string) $condition;
        } elseif (empty($condition)) {
            return '';
        }
        if (isset($condition[0])) {
            // operator format: operator, operand 1, operand 2, ...
            $operator = strtoupper($condition[0]);
            if (isset($this->conditionBuilders[$operator])) {
                $method = $this->conditionBuilders[$operator];
            } else {
                $method = 'buildSimpleCondition';
            }
            array_shift($condition);
            return $this->{$method}($operator, $condition, $params);
        } else {
            // hash format: 'column1' => 'value1', 'column2' => 'value2', ...
            return $this->buildHashCondition($condition, $params);
        }
    }