Hi,

I'm running a custom query that adds up the total number of
establishments (bars, stores, etc.) in a city and then order then my by
this total:

$aTopCitiesList = $this->query('SELECT `cities`.`id`, `cities`.`name`,
count( `establishments`.`name` ) AS `total`
                FROM `cities`
                LEFT JOIN `establishments` ON `establishments`.`city_id` =
`cities`.`id`
                GROUP BY `cities`.`name`
                ORDER BY `total` DESC , `cities`.`name` ASC
                LIMIT 12 ');

This returns a result set like:

   [0] => Array
       (
           [cities] => Array
               (
                   [id] => 28
                   [name] => Barrie
               )

           [0] => Array
               (
                   [total] => 181
               )

       )
....

I'm wondering why Cake is returning each row as two separate arrays
instead of just adding the total to the [cities] array. I'm thinking of
just post-processing this to put the total into the cities array, but
I'm wondering if I need to re-state the query a different way?

(btw: I noticed if I use execute instead of query, the total field is
dropped from the results completely)

Thanks, Zoltan www.yyztech.ca - Toronto cybercafes, reviews


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to