开发者

Yii paginate related data

What is the best way to paginate related data in Yii?

For example I may have post and I want 开发者_C百科to paginate comments.


This can be achieved by using code like this, suppose you have CommentController.php having:

function listComments(){

 /* Write code here to fetch comments with current post from db and 
    return template code via calling renderPartial(). 
    Also implement paging, sorting etc. in this same function.
 */

}

After that call this function in action for view post page and pass the comment's listing code in view post template.


Look into CActiveDataProvider it already has inbuilt pagination support.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜