yii\sphinx\QueryBuilder::buildHashCondition PHP Метод

buildHashCondition() публичный Метод

Creates a condition based on column-value pairs.
public buildHashCondition ( IndexSchema[] $indexes, array $condition, array &$params ) : string
$indexes IndexSchema[] list of indexes, which affected by query
$condition array the condition specification.
$params array the binding parameters to be populated
Результат string the generated SQL expression
    public function buildHashCondition($indexes, $condition, &$params)
    {
        $parts = [];
        foreach ($condition as $column => $value) {
            if (is_array($value) || $value instanceof Query) {
                // IN condition
                $parts[] = $this->buildInCondition($indexes, 'IN', [$column, $value], $params);
            } else {
                if (strpos($column, '(') === false) {
                    $quotedColumn = $this->db->quoteColumnName($column);
                } else {
                    $quotedColumn = $column;
                }
                if ($value === null) {
                    $parts[] = "{$quotedColumn} IS NULL";
                } else {
                    $parts[] = $quotedColumn . '=' . $this->composeColumnValue($indexes, $column, $value, $params);
                }
            }
        }
        return count($parts) === 1 ? $parts[0] : '(' . implode(') AND (', $parts) . ')';
    }