Thursday, October 18, 2012

Cakephp find order by then group by

Hello In a Message controller I try to display the latest message of each user (sender) for a connected one (receiver)  I try this but I still find the first entry. Thank you for your help

Messages table:

  • id
  • user_id -> Sender
  • receiver_id -> receiver
  • content 
  • created -> datetime
  • statut -> read or not

$this->set('messages', $this->Message->find('all',
array
(
'conditions' => array('Message.receiver_id'=>$user),
'order' => array('Message.created desc'),
'group'=>'Message.user_id')));

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

No comments: