I cant get rid of some “duplicates” in this query:
$data = $this->Collection->find('first', array(
'conditions' => array('Collection.id' => $id),
'Collection' => array(
'fields' => array(
'Collection.name'
),
),
'contain' => array(
'Product' => array(
'fields' => array(
'id'
),
'order' => 'lft ASC',
),
'Product.Detail' => array(
'fields' => array(
'product_id', // should occur only once
'image_1_zoom',
'image_1_slide',
'image_1_detail',
'image_1_thumb',
),
))));
Detail belongsTo Product and Product hasMany Detail.
My problem is, that I dont want to get more than one Detail with the same product_id.
I tried ‘group’ with no success. DISTINCT is not possible, since the other fields have different content and are no “real” duplicates.
Any ideas greatly appreciated! 🙂
Try putting
'limit'=>1in yourProduct.Detailarray!