PHP 클래스 yii\data\ActiveDataProvider

ActiveDataProvider provides data by performing DB queries using [[query]]. The following is an example of using ActiveDataProvider to provide ActiveRecord instances: php $provider = new ActiveDataProvider([ 'query' => Post::find(), 'pagination' => [ 'pageSize' => 20, ], ]); get the posts in the current page $posts = $provider->getModels(); And the following example shows how to use ActiveDataProvider without ActiveRecord: php $query = new Query(); $provider = new ActiveDataProvider([ 'query' => $query->from('post'), 'pagination' => [ 'pageSize' => 20, ], ]); get the posts in the current page $posts = $provider->getModels(); For more details and usage information on ActiveDataProvider, see the guide article on data providers.
부터: 2.0
저자: Qiang Xue ([email protected])
상속: extends BaseDataProvider
파일 보기 프로젝트 열기: yiisoft/yii2 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$db the DB connection object or the application component ID of the DB connection. If not set, the default DB connection will be used. Starting from version 2.0.2, this can also be a configuration array for creating the object.
$key the column that is used as the key of the data models. This can be either a column name, or a callable that returns the key value of a given data model. If this is not set, the following rules will be used to determine the keys of the data models: - If [[query]] is an ActiveQuery instance, the primary keys of [[\yii\db\ActiveQuery::modelClass]] will be used. - Otherwise, the keys of the [[models]] array will be used.
$query the query that is used to fetch data models and [[totalCount]] if it is not explicitly set.

공개 메소드들

메소드 설명
init ( ) Initializes the DB connection component.
setSort ( $value )

보호된 메소드들

메소드 설명
prepareKeys ( $models )
prepareModels ( )
prepareTotalCount ( )

메소드 상세

init() 공개 메소드

This method will initialize the [[db]] property to make sure it refers to a valid DB connection.
public init ( )

prepareKeys() 보호된 메소드

protected prepareKeys ( $models )

prepareModels() 보호된 메소드

protected prepareModels ( )

prepareTotalCount() 보호된 메소드

protected prepareTotalCount ( )

setSort() 공개 메소드

public setSort ( $value )

프로퍼티 상세

$db 공개적으로 프로퍼티

the DB connection object or the application component ID of the DB connection. If not set, the default DB connection will be used. Starting from version 2.0.2, this can also be a configuration array for creating the object.
public $db

$key 공개적으로 프로퍼티

the column that is used as the key of the data models. This can be either a column name, or a callable that returns the key value of a given data model. If this is not set, the following rules will be used to determine the keys of the data models: - If [[query]] is an ActiveQuery instance, the primary keys of [[\yii\db\ActiveQuery::modelClass]] will be used. - Otherwise, the keys of the [[models]] array will be used.
또한 보기: getKeys()
public $key

$query 공개적으로 프로퍼티

the query that is used to fetch data models and [[totalCount]] if it is not explicitly set.
public $query