Re: How to specify a count(id) field for find method
Thanks for your reply euromark.
I tried the find->('count'.... but it just returns a number, not the
records grouped by 'status' field.
On 14 ago, 15:09, euromark <dereurom...@googlemail.com> wrote:
> $this->Member->find('count', ...)
> it should be in the cookbook, the documentation of cakephp
>
> On 14 Aug., 22:29, Roland Pish <rolandp...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Hello.
> > I need to issue a query like:
>
> > select count(id) as total,status from members group by status
>
> > When specifying the fields for the model find method I do this:
>
> > $fields = array('count(Member.id) as total','Member.status');
> > $members = $this->Member->find('all',array('fields'=>
> > $fields,'group'=>'Member.status'));
>
> > But the resulting array doesn't put 'total' field within
> > $members['Member'] but in $members[0]. How should I write the 'total'
> > field in order to be pushed into $members['Member']?
>
> > Thanks in advance
--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home