PHP Класс yii\data\BaseDataProvider

С версии: 2.0
Автор: Qiang Xue ([email protected])
Наследование: extends yii\base\Component, implements yii\data\DataProviderInterface
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$id an ID that uniquely identifies the data provider among all data providers. You should set this property if the same page contains two or more different data providers. Otherwise, the [[pagination]] and [[sort]] may not work properly.

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

Метод Описание
getCount ( ) : integer Returns the number of data models in the current page.
getKeys ( ) : array Returns the key values associated with the data models.
getModels ( ) : array Returns the data models in the current page.
getPagination ( ) : Pagination | false Returns the pagination object used by this data provider.
getSort ( ) : Sort | boolean Returns the sorting object used by this data provider.
getTotalCount ( ) : integer Returns the total number of data models.
prepare ( boolean $forcePrepare = false ) Prepares the data models and keys.
refresh ( ) Refreshes the data provider.
setKeys ( array $keys ) Sets the key values associated with the data models.
setModels ( array $models ) Sets the data models in the current page.
setPagination ( array | Pagination | boolean $value ) Sets the pagination for this data provider.
setSort ( array | Sort | boolean $value ) Sets the sort definition for this data provider.
setTotalCount ( integer $value ) Sets the total number of data models.

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

Метод Описание
prepareKeys ( array $models ) : array Prepares the keys associated with the currently available data models.
prepareModels ( ) : array Prepares the data models that will be made available in the current page.
prepareTotalCount ( ) : integer Returns a value indicating the total number of data models in this data provider.

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

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

Returns the number of data models in the current page.
public getCount ( ) : integer
Результат integer the number of data models in the current page.

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

Returns the key values associated with the data models.
public getKeys ( ) : array
Результат array the list of key values corresponding to [[models]]. Each data model in [[models]] is uniquely identified by the corresponding key value in this array.

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

Returns the data models in the current page.
public getModels ( ) : array
Результат array the list of data models in the current page.

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

Note that you should call BaseDataProvider::prepare or BaseDataProvider::getModels first to get correct values of [[Pagination::totalCount]] and [[Pagination::pageCount]].
public getPagination ( ) : Pagination | false
Результат Pagination | false the pagination object. If this is false, it means the pagination is disabled.

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

Returns the sorting object used by this data provider.
public getSort ( ) : Sort | boolean
Результат Sort | boolean the sorting object. If this is false, it means the sorting is disabled.

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

When [[pagination]] is false, this returns the same value as [[count]]. Otherwise, it will call BaseDataProvider::prepareTotalCount to get the count.
public getTotalCount ( ) : integer
Результат integer total number of possible data models.

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

This method will prepare the data models and keys that can be retrieved via BaseDataProvider::getModels and BaseDataProvider::getKeys. This method will be implicitly called by BaseDataProvider::getModels and BaseDataProvider::getKeys if it has not been called before.
public prepare ( boolean $forcePrepare = false )
$forcePrepare boolean whether to force data preparation even if it has been done before.

prepareKeys() абстрактный защищенный Метод

Prepares the keys associated with the currently available data models.
abstract protected prepareKeys ( array $models ) : array
$models array the available data models
Результат array the keys

prepareModels() абстрактный защищенный Метод

Prepares the data models that will be made available in the current page.
abstract protected prepareModels ( ) : array
Результат array the available data models

prepareTotalCount() абстрактный защищенный Метод

Returns a value indicating the total number of data models in this data provider.
abstract protected prepareTotalCount ( ) : integer
Результат integer total number of data models in this data provider.

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

After calling this method, if BaseDataProvider::getModels, BaseDataProvider::getKeys or BaseDataProvider::getTotalCount is called again, they will re-execute the query and return the latest data available.
public refresh ( )

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

Sets the key values associated with the data models.
public setKeys ( array $keys )
$keys array the list of key values corresponding to [[models]].

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

Sets the data models in the current page.
public setModels ( array $models )
$models array the models in the current page

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

Sets the pagination for this data provider.
public setPagination ( array | Pagination | boolean $value )
$value array | Pagination | boolean the pagination to be used by this data provider. This can be one of the following: - a configuration array for creating the pagination object. The "class" element defaults to 'yii\data\Pagination' - an instance of [[Pagination]] or its subclass - false, if pagination needs to be disabled.

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

Sets the sort definition for this data provider.
public setSort ( array | Sort | boolean $value )
$value array | Sort | boolean the sort definition to be used by this data provider. This can be one of the following: - a configuration array for creating the sort definition object. The "class" element defaults to 'yii\data\Sort' - an instance of [[Sort]] or its subclass - false, if sorting needs to be disabled.

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

Sets the total number of data models.
public setTotalCount ( integer $value )
$value integer the total number of data models.

Описание свойств

$id публичное свойство

an ID that uniquely identifies the data provider among all data providers. You should set this property if the same page contains two or more different data providers. Otherwise, the [[pagination]] and [[sort]] may not work properly.
public $id