Monday, November 30, 2009

Re: Problem with having count(*)

If I understand you correctly, I think you can achieve that by passing
certain parameters to the find() function.
Take a look at these:
http://book.cakephp.org/view/73/Retrieving-Your-Data#find-449
http://book.cakephp.org/view/73/Retrieving-Your-Data#Complex-Find-Conditions-74

I'm new to cakephp, also, but maybe something like this might work
(depending on your setup):

$param = array(
'group' => array('User.id HAVING COUNT(Album.id) > 0'),
);

$this->User->find('all', $param);


On Nov 30, 12:26 am, Gaurang <gaurang...@gmail.com> wrote:
> Hi
>
> I am relatively new to cake-php but i like it very much. But in my
> current project i have a problem regarding having query
>
> I have a Model called User and other model called Album.
>
> Now i want to display a list of users having at least one Album. My
> user model has others relations also like
>
> User has many Photos
> User has many Comments
> User has many Links
>
> I tried to google it and also tried to think by my self but could not
> find a solution.
>
> I can achive this using Model->query but i think it is not a good way
> to code cakephp.
>
> Can anyone help me this issue?
>
> Thanks
>
> Gaurnag

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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?hl=en

No comments: