Hm.. I tried that and no luck. So close though... Putting 1=1 GROUP BY... into a condition puts it into the query but Containable puts the foreign key constraint on the end after it and so MySQL ignores the group by statement. If I change the order and run the query myself it returns what I want.
Since the results I am going for can't be that uncommon, maybe I am going about it the wrong way? I have a number of Question(s), each hasMany Answer(s). I want to find all questions and contain the count of the answers for each Question grouped by the Answer.text (Answers are mostly simple YES, NO, A, B, C). The alternative to containing, I know of, is to loop the found questions and find the grouped answers for each in separate queries... or doing a custom query but I'd rather not do that. On Jun 12, 7:57 am, Martin Westin <[email protected]> wrote: > Thanks Brian, > So, you have to trick Containable by puting it into a condition ... > like the good old days :) > > /Martin > > On Jun 11, 6:01 pm, brian <[email protected]> wrote: > > > > > Have a look at this thread: > > >http://groups.google.com/group/cake-php/browse_thread/thread/4b1351b6... > > > On Thu, Jun 11, 2009 at 11:45 AM, Martin > > > Westin<[email protected]> wrote: > > > > Hi, > > > I find myself needing to get associated data grouped by a field but > > > Containable seems to interpret the group key as an extra field to > > > include. > > > > @line 267 containable specifies a bunch of valid options but groups is > > > not one of them. > > > > Trying to be cheeky and adding group to the list makes the errors go > > > away but the group statement is still ignored... and that is as far as > > > I have come trying to understand the internals of Containable. > > > > My question is if the missing group is a small oversight that can be > > > easily implemented or if grouping has been intentionally abandoned > > > after it proved to be too complex, or something? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" 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 -~----------~----~----~----~------~----~------~--~---
