views:

54

answers:

1

Currently I'm deal with a history message page using Cakephp.And I got a problem about records' order.In the controller,codes about pagination as follows

$this->paginate['Msg'] = array('order'=>'Msg.created desc');
$msgs = $this->paginate('Msg');
$this->set('historymsgs',$msgs);

Then I got the first page which contains the latest messges like this:

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!

But what I need is the reversed order of the messages.How can I append a condition of Msg.created asc here?

Thanks in advance.

+2  A: 

So, in short, you want the first page to show the most recent history but, on each page, you want the messages to show in chronological order instead of reverse-chronological.

If so, you could try to use Set::sort() on the data set from each page.

Xr
Done,thanks~~~!
SpawnCxy