Reputation: 696
I have the following segment of code in which I want to Group everything by the Release.id since I am getting a lot of duplicates. Even though I have a DISTINCT, it completely gets ignored.
Can someone guide me in the right direction?
$this->Release->recursive = 0;
$this->paginate['Release']['joins'] =
array(
array(
'table' => 'game_potential_amazon_matches',
'alias' => 'PotentialAmazonMatch',
'type' => 'inner',
'conditions' =>
array(
'PotentialAmazonMatch.release_id = Release.id'
),'fields' => array('DISTINCT Release.id')
)
);
$this->set('releases', $this->paginate('Release'));
RELEASE TABLE
id
name
asin
MATCHES TABLE
date
asin
release_id
The matches table has a one to many relationship with Release table. I just want a single release.
Upvotes: 1
Views: 104
Reputation: 1826
You are now defining 'fields' => array('DISTINCT Release.id')
in array
$this->paginate['Release']['joins'].
Try to place it after conditions in $this->paginate['Release'].
Upvotes: 1