Cakephp 1.2 分页
我需要在 CakePHP 1.2 中自定义查询分页。
我有一个评论模型,在一组页面上,它以一种方式对评论模型进行分页,而在另一组页面上,它使用不同的自定义查询以另一种方式进行分页。如何在同一模型中覆盖 paginate 和 paginateCount 两次?
I need a custom query pagination in CakePHP 1.2.
I have a reviews model and on one set of pages, it paginates the reviews model one way, and on another set of pages it does it another way with a different custom query. How do I overwrite paginate and paginateCount twice in the same model?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
恕我直言,
我不会在同一个模型中这样做。
根据您的要求,我将有两个具有不同覆盖的不同模型,并相应地在分页方法中使用它们。
类似的东西。
$this->paginate('超级评论');
$this->paginate('Normalreviews');
显然,在这两个模型类中,您都会有:
var $name = 'Review';
华泰
IMHO
I wouldn't do it in the same model.
I would have two different models with different overwrites depending on your requirements and use them in the paginate method accordingly.
Something like.
$this->paginate('Superreviews');
$this->paginate('Normalreviews');
Obviously in both model classes you would have:
var $name = 'Review';
HTH