yii\sphinx\QueryBuilder::buildSimpleCondition PHP 메소드

buildSimpleCondition() 공개 메소드

Creates an SQL expressions like "column" operator value.
public buildSimpleCondition ( IndexSchema[] $indexes, string $operator, array $operands, array &$params ) : string
$indexes IndexSchema[] list of indexes, which affected by query
$operator string the operator to use. Anything could be used e.g. `>`, `<=`, etc.
$operands array contains two column names.
$params array the binding parameters to be populated
리턴 string the generated SQL expression
    public function buildSimpleCondition($indexes, $operator, $operands, &$params)
    {
        if (count($operands) !== 2) {
            throw new InvalidParamException("Operator '{$operator}' requires two operands.");
        }
        list($column, $value) = $operands;
        if (strpos($column, '(') === false) {
            $column = $this->db->quoteColumnName($column);
        }
        if ($value === null) {
            return "{$column} {$operator} NULL";
        } elseif ($value instanceof Expression) {
            foreach ($value->params as $n => $v) {
                $params[$n] = $v;
            }
            return "{$column} {$operator} {$value->expression}";
        } else {
            $phName = self::PARAM_PREFIX . count($params);
            $params[$phName] = $value;
            return "{$column} {$operator} {$phName}";
        }
    }