【发布时间】:2010-03-23 15:24:08
【问题描述】:
目前我正在使用 Cakephp 处理历史消息页面。我遇到了关于记录顺序的问题。在控制器中,关于分页的代码如下
$this->paginate['Msg'] = array('order'=>'Msg.created desc');
$msgs = $this->paginate('Msg');
$this->set('historymsgs',$msgs);
然后我得到了包含最新消息的第一页,如下所示:
tom:I'm eighteen.
Jerry:How old are you?
tom:Tom.
Jerry:what's your name?
tom:Hi nice to meet you too!
Jerry:Hello,nice to meet you!
但我需要的是消息的相反顺序。如何在此处附加Msg.created asc 的条件?
提前致谢。
【问题讨论】:
-
在您的代码中将
desc更改为asc? -
@Col。弹片...远远不止一页,我需要在第一页显示最新消息。
-
那又怎样? asc 有什么问题?
-
所以最新消息会在最后一页!
-
好的,好的。最新但顺序相反。好吧,您必须找到一种重新排序结果集的方法。如果它是普通的 PHP,我只会使用
rsort(),但由于它不是 php 而是蛋糕,你必须找到一种蛋糕方式。文档可能会有所帮助
标签: php cakephp pagination