On Mon, Apr 7, 2008 at 2:32 AM, hks <[EMAIL PROTECTED]> wrote:
>
> Hello, I'd like to use CakePHP convention in querying the following
>
> SELECT
> tags.name AS tag_name,
> COUNT(ads_tags.tag_id) AS tag_count,
> MAX(ads_tags.created) AS tag_date
> FROM
> tags INNER JOIN
> ads_tags ON tags.id = ads_tags.tag_id INNER JOIN
> ads ON ads.id = ads_tags.ad_id AND ads.closed = 0 AND ads.suspended =
> 0 AND ads.hidden = 0
> GROUP BY
> tags.name
To use GROUP BY, you have to pass a condition like this:
$conditions = array("1=1 GROUP BY tags.name")
$this->Model->findAll(compact('conditions'))
Hope that helps.
--
Chris Hartjes
Internet Loudmouth
Motto for 2008: "Moving from herding elephants to handling snakes..."
@TheKeyBoard: http://www.littlehart.net/atthekeyboard
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---