PHP Класс yii\sphinx\ActiveDataProvider

It allows to fetch not only rows and total rows count, but also a meta information and facet results. The following is an example of using ActiveDataProvider to provide facet results: php $provider = new ActiveDataProvider([ 'query' => Post::find()->facets(['author_id', 'category_id']), 'pagination' => [ 'pageSize' => 20, ], ]); get the posts in the current page $posts = $provider->getModels(); get all facets $facets = $provider->getFacets(); get particular facet $authorFacet = $provider->getFacet('author_id'); In case [[Query::showMeta]] is set ActiveDataProvider will fetch total count value from the query meta information, avoiding extra counting query: php $provider = new ActiveDataProvider([ 'query' => Post::find()->showMeta(true), 'pagination' => [ 'pageSize' => 20, ], ]); $totalCount = $provider->getTotalCount(); // fetched from meta information Note: when using 'meta' information results total count will be fetched after pagination limit applying, which eliminates ability to verify if requested page number actually exist. Data provider disables yii\data\Pagination::validatePage automatically in this case. Note: because pagination offset and limit may exceed Sphinx 'max_matches' bounds, data provider will set 'max_matches' option automatically based on those values. However, if [[Query::showMeta]] is set, such adjustment is not performed as it will break total count calculation, so you'll have to deal with 'max_matches' bounds on your own.
С версии: 2.0.4
Автор: Paul Klimov ([email protected])
Наследование: extends yii\data\ActiveDataProvider
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
getFacet ( string $name ) : array Returns results of the specified facet.
getFacets ( ) : array
getMeta ( ) : array
setFacets ( array $facets )
setMeta ( array $meta )

Защищенные методы

Метод Описание
prepareModels ( )
prepareTotalCount ( )

Описание методов

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

Returns results of the specified facet.
public getFacet ( string $name ) : array
$name string facet name
Результат array facet results.

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

public getFacets ( ) : array
Результат array query facet results.

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

public getMeta ( ) : array
Результат array search query meta info

prepareModels() защищенный Метод

protected prepareModels ( )

prepareTotalCount() защищенный Метод

protected prepareTotalCount ( )

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

public setFacets ( array $facets )
$facets array query facet results.

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

public setMeta ( array $meta )
$meta array search query meta info