Re: Cakephp find order by then group by
As Jeremy said, use find('first') because you only want one message.
And Jonathon is correct -- drop the group option.
On Thu, Oct 18, 2012 at 5:47 AM, anwar korti <anwarkorti@gmail.com> wrote:
> 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.
>
>
--
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.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home