I don't see a reason for using grouping in this query. 'Group by' is
only needed if you want to use some aggregation functions like SUM,
AVG, MAX, MIN etc. If you don't use them, you don't need 'group by' in
your query. I think that use of 'order by' would be enough in your
situation, so you need to add an order value to findAll to order it by
photo_id.

On 20 Sty, 23:10, 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 [email protected]
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to