Answers for "yii2 arraydataprovider"

PHP
0

yii2 arraydataprovider

$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();
Posted by: Guest on June-19-2020

Browse Popular Code Answers by Language