darioo
(Timmy Dario)
1
I’m using GridView and ListView for showing articles, one per page. I have 100 pages.
$searchModel = new StorySearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams,$type, $id);
Is $dataProvider (StorySearch) called every time I click on button to go to next page?
alirz23
(Ali Raza)
2
that is right every time you click on the next button search method is executed.
darioo
(Timmy Dario)
3
So every time query is executed and my database suffers a little bit?
Is there way to make it easier for database?
Hey,
Since I have not much experience with it my anser could be wrong.
But I would answer your question with:
Yes. When you cache your query / results.
Read:
http://www.yiiframework.com/doc-2.0/guide-caching-data.html
Regards
alex-w
(Pr0j3ct A1ex)
5
Depending if you have any relations or not at minimum two queries will be executed.
One will get the ‘Count’ of all the rows based off the current search and the second will return by default 20 rows.
Unless you have bad/no indexes I doubt the db suffers much.