I currently use a straight SQL statement for this but I'm wondering if
there is any way to do this with $this->model->find(). I have a User
model that hasMany ratings. What I want to do is select all users that
have no ratings. This is how I do it now:

$sql="SELECT * FROM users WHERE (SELECT COUNT(id) FROM ratings WHERE
ratings.user_id=users.id)=0";
$results=$this->User->query($sql);

Is there a way to do this with find? how about selecting all users
where user's ratings satisfy conditions:

$sql="SELECT * FROM users WHERE (SELECT COUNT(id) FROM ratings WHERE
ratings.user_id=users.id AND ratings.value>=10)>0";
$results=$this->User->query($sql);

just wondering if anyone knows if this is possible using find().
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to