I'm guessing User hasMany Assignements?
You're looking for an INNER JOIN. Currently, CakePHP doesn't support
this. You can simulate it, but binding a dummy hasOne on your User
model with the Assignment. You'd need to call it something else
(hasOne AssignmentDummy), and add a condition: "Assignment.id IS NOT
NULL" (I think).
http://groups.google.com/group/cake-php/browse_thread/thread/77cc061717aafd0b/145ec0f124b9b75b?lnk=gst&q=inner+join#145ec0f124b9b75b
On Tue, Mar 4, 2008 at 12:01 PM, teknoid <[EMAIL PROTECTED]> wrote:
>
> Hi,
> I am using bindable behavior and trying to construct a conditional
> query, by passing conditions to mutiple models.
> For example, I have this query:
>
> $result = $this->User->find('all', array('restrict' =>
> array( 'Assignment'
> => array('conditions' =>
> 'Assignment.IsAccepted=1',
> 'fields' =>
> 'Assignment.UserID',
> 'Document' => array('conditions' =>
> 'Document.ProfileID IN
> (38)',
> 'fields' => 'Document.ProfileID',
> 'Item' => array('fields' => 'ItemProd.ItemInfoID',
> 'ItemInfo'
> => array('conditions' =>
> 'ItemInfo.ItemText LIKE "W
> %"')))))));
>
> The query will match and return the correct fields for each model, but
> also this query returns "extra" data with empty arrays. For example it
> will still return all users, even though their relevant
> Assignment.IsAccepted does not equal to 1 (in that case it will simply
> return an empty array for that user's assignment as part of the
> overall resultset). Ideally it would be great to receive only the User
> (and related models) only when all of the conditions in the above
> query are met.
>
> What could be done to make that happen?
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---