I posted a similar query here last week. I was hoping to use Set class to do the same. I guess grigri wasn't around ;-)
Teknoid suggested this method: http://teknoid.wordpress.com/2008/09/29/dealing-with-calculated-fields-in-cakephps-find/ On Tue, Feb 3, 2009 at 8:41 PM, Miles J <[email protected]> wrote: > > Ok I got it working, but its outside of the array I want. Anyway to > get it in there? > > [TeamsUser] => Array > ( > [id] => 1 > [team_id] => 1 > [user_id] => 2 > [role] => leader > [status] => approved > [joinDate] => 1231636154 > ) > > [0] => Array > ( > [totalMembers] => 6 > ) > > Heres my query: > > 'fields' => array('TeamsUser.*', "(SELECT COUNT(id) FROM teams_users > AS TeamsUser WHERE TeamsUser.team_id = Team.id AND TeamsUser.status = > 'approved') AS totalMembers") > > I tried doing AS TeamsUser.totalMembers and it didnt work. > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
