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.