CakePHP find('threaded') 分页
我对 cakePHP 有点陌生,现在我必须进行分页。
评论表有一个parent_id,并且线程查询工作正常,所以现在我想对结果进行分页。
我的问题是有限的 sql 查询会影响所有检索到的评论,我只想限制父级评论,因为相反,它会将回复排除在查询之外。
希望我能说清楚,你能帮助我。
谢谢。
I'm kind of new to cakePHP and get to the moment where i have to do pagination.
The comments table has a parent_id and the threaded query is working correctly so now, I want to paginate the results.
My problem is the limited sql query affects all the retrieved comments and I only want to limit the parent ones because the other way, it leaves replies out of the query.
Hope I'd be clear and you can help me.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用:
然后在查找中:
您必须根据您的目的自定义代码,但关键点是关系,并且查找条件具有parent_id = null。这样限制只影响父母
Use:
and then in the find:
You have to customize the code for your purpose, but the keypoint is the relations and that the find condition has parent_id = null. This way the limit only affects the parents
您可能需要仅对父级(主题?)进行查询,然后对下面的每棵树进行另一个查询。
You probably need to do the query for just the parents (topics?) then another query for each tree below that.