Hellow , I want to use group by within contain in cakephp. In the following case i want to take only distinct organization within organizationUser array..
$options = array(
'conditions' => array('User.' .$this->User->primaryKey => $userId),
'contain' => array(
'group'=> array( 'OrganizationUser.organization_id')),
$org = $this->User->find('all', $options);
I don't think cakephp 2+ offer something like you are doing to make field distinct within contain. So better to try following.. Replace :
'group'=> array( 'OrganizationUser.organization_id')
'fields'=> array( 'DISTINCT OrganizationUser.organization_id')
that might work for you.