0 關注者

介面 yii\data\DataProviderInterface

實作於yii\data\ActiveDataProvider, yii\data\ArrayDataProvider, yii\data\BaseDataProvider, yii\data\SqlDataProvider
自版本2.0
原始碼 https://github.com/yiisoft/yii2/blob/master/framework/data/DataProviderInterface.php

DataProviderInterface 是資料提供者類別必須實作的介面。

資料提供者是元件,用於排序和分頁資料,並將其提供給諸如 yii\grid\GridViewyii\widgets\ListView 等小工具。

關於 DataProviderInterface 的更多詳細資訊和使用方法,請參閱關於資料提供者的指南文章

公開方法

隱藏繼承方法

方法 描述 定義於
getCount() 傳回目前頁面中的資料模型數量。 yii\data\DataProviderInterface
getKeys() 傳回與資料模型相關聯的鍵值。 yii\data\DataProviderInterface
getModels() 傳回目前頁面中的資料模型。 yii\data\DataProviderInterface
getPagination() yii\data\DataProviderInterface
getSort() yii\data\DataProviderInterface
getTotalCount() 傳回資料模型的總數。 yii\data\DataProviderInterface
prepare() 準備資料模型和鍵值。 yii\data\DataProviderInterface

方法詳情

隱藏繼承方法

getCount() public abstract method

傳回目前頁面中的資料模型數量。

這等同於 count($provider->getModels())。當 pagination 為 false 時,這與 totalCount 相同。

public abstract integer getCount ( )
return integer

當前頁面的資料模型數量。

                public function getCount();

            
getKeys() 公開抽象方法

傳回與資料模型相關聯的鍵值。

public abstract array getKeys ( )
return 陣列

對應於 models 的鍵值列表。models 中的每個資料模型都由此陣列中對應的鍵值唯一識別。

                public function getKeys();

            
getModels() 公開抽象方法

傳回目前頁面中的資料模型。

public abstract array getModels ( )
return 陣列

當前頁面的資料模型列表。

                public function getModels();

            
getPagination() 公開抽象方法

public abstract yii\data\Pagination|false getPagination ( )
return yii\data\Pagination|false

分頁物件。如果這是 false,則表示分頁已停用。

                public function getPagination();

            
getSort() 公開抽象方法

public abstract yii\data\Sort|false getSort ( )
return yii\data\Sort|false

排序物件。如果這是 false,則表示排序已停用。

                public function getSort();

            
getTotalCount() 公開抽象方法

傳回資料模型的總數。

pagination 為 false 時,這與 count 相同。

public abstract integer getTotalCount ( )
return integer

可能的資料模型總數。

                public function getTotalCount();

            
prepare() 公開抽象方法

準備資料模型和鍵值。

此方法將準備可透過 getModels()getKeys() 檢索的資料模型和鍵。

如果之前未呼叫過此方法,則會由 getModels()getKeys() 隱式呼叫。

public abstract void prepare ( $forcePrepare false )
$forcePrepare 布林值

即使之前已完成,是否強制執行資料準備。

                public function prepare($forcePrepare = false);