Yep, I've seen and tried that before, but I can't get it to work with
multiple tables/models.

On Mar 5, 2:00 pm, Baz <[EMAIL PROTECTED]> wrote:
> Check the thread that I included before
>
>
>
> On Wed, Mar 5, 2008 at 10:55 AM, teknoid <[EMAIL PROTECTED]> wrote:
>
> >  Oh boy :(
>
> >  Thank you for the encouragment, however.
> >  Would you mind pasting some code/pseudo code that works for you?
> >  (Hopefully if you have one with chained tables)
>
> >  Do you also use bindable?
>
> >  On Mar 5, 11:19 am, Baz <[EMAIL PROTECTED]> wrote:
> >  > Trust me, revisit the hasOne.
>
> >  > I've been trying to do this for months (include the ugly step through
> >  > hack). The hasOne works for me.
>
> > > On Wed, Mar 5, 2008 at 9:17 AM, teknoid <[EMAIL PROTECTED]> wrote:
>
> >  > >  I've tried the hasOne trick, but it doesn't seem to do the job I
> >  > >  need.
> >  > >  Basically because I have a chain of a few tables I would like to apply
> >  > >  some condition to each one of the tables and get the relevant result.
> >  > >  While in this case all the conditions get applied properly, the end
> >  > >  result comes with "extra" data. I guess I need to wait for the
> >  > >  'type'=>'INNER' fix because I just don't see any other way to create
> >  > >  multiple joins with conditions in one query...
>
> >  > >  Temporary *ugly* solution is to walk through the resulting array and
> >  > >  unset all the empty arrays returned by the query, then do a manual
> >  > >  count or grab the needed data :(
>
> >  > >  thanks for any further suggestions...
>
> >  > >  On Mar 4, 1:59 pm, Baz <[EMAIL PROTECTED]> wrote:
> >  > >  > 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/77cc0617...
>
> >  > >  > 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?- Hide quoted text -
>
> >  > >  > - Show quoted text -- Hide quoted text -
>
> >  > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
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