1
votes

I am trying create ArrayDataProvider. I am calling dataProvider like this:

$dataProvider = new ArrayDataProvider([
     'allModels' => $query->from('posts')->all(),
     'pagination' => [
          'pageSize' => 10,
     ],
]);

Here I am using pageSize. When I run this code in sql not showing LIMIT, but pagination is working. I have more than 100 posts and all of them loading in all time. Generated SQL Query: SELECT * FROMposts. What I must do to solve this. Thank you!

1
Why not use ActiveDataProvider instead? - topher
Its simple example. I am using relational tables. There are 6 tables connected to this query. - iProgrammer
I cant use ActiveDataProvider because every item uses another table details. It means for each item need 6 additional queries. If you calculate for 10 item I must run 61 selects. - iProgrammer
OK. As the documentation states: $allModels is the data that is not paginated or sorted. You have to find some way of passing the pageSize as a limit on the $query. - topher
Ok thank you. I will try this - iProgrammer

1 Answers

0
votes

Try this

'pageSizeLimit' => [5,100],