📜  yii2 arraydataprovider - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:43.937000             🧑  作者: Mango

代码示例1
$query = new Query;
$provider = new ArrayDataProvider([
    'allModels' => $query->from('post')->all(),
    'sort' => [
        'attributes' => ['id', 'username', 'email'],
    ],
    'pagination' => [
        'pageSize' => 10,
    ],
]);
// get the posts in the current page
$posts = $provider->getModels();