Pagination for several models

Pleasу, help. How to use pagination for the several models at the same time.




$criteria=new CDbCriteria;

$news =  News::model()->findAll($criteria);

....

$criteria=new CDbCriteria;

$shares = Share::model()->findAll($criteria);

... 

$pages=new CPagination();

<img src='http://www.yiiframework.com/forum/public/style_emoticons/default/huh.gif' class='bbc_emoticon' alt='???' />










       

  

do you want to join the two tables?

Yes

And i need have one pagination on the result page

the pagination doesn’t care which data from where you are showing. You just need to assign the count value of all results to the pagination component and afterwards you need to apply the paginations limit to your db query.

Doing this with active records sounds a little complicated to me, because you have to different querys (min. one for each model) and therefore you would need to make the decision which rows should be shown by hand i think.

the pagination doesn’t care which data from where you are showing. You just need to assign the count value of all results to the pagination component and afterwards you need to apply the paginations limit to your db query.

Doing this with active records sounds a little complicated to me, because you have to different querys (min. one for each model) and therefore you would need to make the decision which rows should be shown by hand i think.

I see.But i have two or three different criteria and paginations limit dont works.There is a better way to view result of searching from different tables with one pagination on the one page?