yii\sphinx\QueryBuilder::build PHP Méthode

build() public méthode

Generates a SELECT SQL statement from a Query object.
public build ( Query $query, array $params = [] ) : array
$query Query the [[Query]] object from which the SQL statement will be generated
$params array the parameters to be bound to the generated SQL statement. These parameters will be included in the result with the additional parameters generated during the query building process.
Résultat array the generated SQL statement (the first array element) and the corresponding parameters to be bound to the SQL statement (the second array element). The parameters returned include those provided in `$params`.
    public function build($query, $params = [])
    {
        $query = $query->prepare($this);
        if (!empty($query->join)) {
            throw new NotSupportedException('Build of "' . get_class($query) . '::join" is not supported.');
        }
        $params = empty($params) ? $query->params : array_merge($params, $query->params);
        $from = $query->from;
        if ($from === null && $query instanceof ActiveQuery) {
            /* @var $modelClass ActiveRecord */
            $modelClass = $query->modelClass;
            $from = [$modelClass::indexName()];
        }
        $clauses = [$this->buildSelect($query->select, $params, $query->distinct, $query->selectOption), $this->buildFrom($from, $params), $this->buildWhere($from, $query->where, $params, $query->match), $this->buildGroupBy($query->groupBy, $query->groupLimit), $this->buildWithin($query->within), $this->buildHaving($query->from, $query->having, $params), $this->buildOrderBy($query->orderBy), $this->buildLimit($query->limit, $query->offset), $this->buildOption($query->options, $params), $this->buildFacets($query->facets, $params)];
        $sql = implode($this->separator, array_filter($clauses));
        $showMetaSql = $this->buildShowMeta($query->showMeta, $params);
        if (!empty($showMetaSql)) {
            $sql .= $this->querySeparator . $showMetaSql;
        }
        return [$sql, $params];
    }