CAKEPHP Group by problem in paginate..

This is my table structure


  Friends Table
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user1_id` int(11) NOT NULL DEFAULT '0',--> UserFrom
  `user2_id` int(11) NOT NULL DEFAULT '0',---> UserTo

I need to get all the unique records of one user and his user1_id = 100

There are lot of duplicate values in user2_id. I need to get the unique
values
While i trying this code it returns only first 12 values(according to
limit).
If i commented the group by line then all records are displaying (including
duplicate values)




  $this->paginate = array(
                        'conditions' => $conditions,
'contain'=>array(
'UserFrom'=>array(
'fields'=>array(
   'UserFrom.id',
   'UserFrom.first_name',
   'UserFrom.last_name',
   ),
 ),
 'UserTo'=>array(
'fields'=>array(
'UserTo.id',
'UserTo.first_name',
'UserTo.last_name',
)
 )
),'limit' => 12,
'order' => array('Friend.id' => 'desc'),
'recursive'=>0,
'fields'=>array('DISTINCT Friend.user2_id','Friend.*'),
'group'=>array('UserTo.id'),
);

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to