1

在 Yii 中对相关数据进行分页的最佳方式是什么?

例如,我可能有帖子,我想对评论进行分页。

4

2 回答 2

1

这可以通过使用这样的代码来实现,假设您有CommentController.php

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.
 */

}

之后调用此函数以查看帖子页面并在查看帖子模板中传递评论的列表代码。

于 2010-07-15T11:06:22.910 回答
0

查看CActiveDataProvider它已经内置了分页支持。

于 2011-03-19T18:26:40.920 回答