OK!! got it working!

Here it is:

$this->User->unbindModel(array('hasMany' => array('Invitation')));
$this->User->bindModel(array('hasOne' => array('Invitation')));
$data = $this->User->find('all',
        array(
                'fields' => array('User.*', 'Invitation.*'),
                'conditions' => array(
                                'Invitation.id' => NULL
                ),
                //'limit' => 100,
                'contain' => array('Invitation')
        )
);

I had to place the unbind AND bind model before, AND the contain.
The unbind was because if not, cake would do another query (pretty
large), not sure what about, but probably made sence considering
hasMany.
The bind was to make cake JOIN the two tables.
the contain Invitation, I dont know why, but did't work without it :P


On Dec 18, 6:50 pm, Ramiro Araujo <[email protected]> wrote:
> no, I'm trying stuff like this:
> $data = $this->User->find('all',
>         array(
>                 'fields' => array('User.*', 'Invitation.*'),
>                 'conditions' => array(
>                                 'Invitation.id' => NULL
>                 ),
>                 'limit' => 100,
>                 'contain' => 'Invitation'
>         )
> );
>
> but the resulting query does not JOIN with Invitation, so I get a
> error on the WHERE condition...
>
> I thought the LEFT JOIN was necessary, but the query works just fine
> with JOIN. I still don't have the complete grasp on the different
> joins, but I do understand they're not actually that different at all.
>
> Anyways, I think that managing to get the join done will make the
> query work, but I tried bindModel to add a hasOne relationship instead
> of hasMany, and didn't work also.
>
> Any more thoughts are appreciated! :)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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