Hi there Something like this might work (untested): $conditionsArr = array('HotelDescriptionPhoto.hotel_id' => $hotel_id, '1=1 GROUP BY HotelDescriptionPhoto.photo_id');
$hotel = $this->Hotel->findAll($conditionsArr); Although you should make sure that you really need a group by - grouping by one column when selecting multiple columns often yields arbitrary results. Good luck Claudia On Jan 20, 11:10 pm, cronet <[EMAIL PROTECTED]> wrote: > Hi, > > I'm siting here for about 2 hours and get it not work. I need a simple > group by in an association. > > This is in my controller: > > $this->Hotel->bindModel( > array('hasMany' => > array( > 'HotelDescriptionTranslation' => array( > 'className' => > 'HotelDescriptionTranslation', > 'foreignKey' => > 'hotel_id', > 'conditions' => $cond1 > > ), > 'HotelDescriptionPhoto' => array( > 'className' => > 'HotelDescriptionPhoto', > 'foreignKey' => 'hotel_id', > 'conditions' => > $cond2 > ) > ) > ), FALSE > ); > $hotel = $this->Hotel->findByHotelId($hotel_id); > > Results in this query: > > SELECT `HotelDescriptionPhoto`.`id`, > `HotelDescriptionPhoto`.`descriptiontype_id`, > `HotelDescriptionPhoto`.`hotel_id`, > `HotelDescriptionPhoto`.`photo_id`, > `HotelDescriptionPhoto`.`url_max300`, > `HotelDescriptionPhoto`.`url_original`, > `HotelDescriptionPhoto`.`url_square60`, > `HotelDescriptionPhoto`.`created`, `HotelDescriptionPhoto`.`modified` > FROM `hotel_description_photos` AS `HotelDescriptionPhoto` WHERE > (descriptiontype_id = '5' OR descriptiontype_id = '10') AND > `HotelDescriptionPhoto`.`hotel_id` IN (60160) > > But I need a "GROUP BY `HotelDescriptionPhoto`.`photo_id`" inside the > query... > > Is there an easy(?!) way to achieve this? (I would not want to create > a custom query)... > > Regards, > Alexander --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---