I have setup where a user "picks" a "game" ...

User hasMany Picks
Picks belongsTo Game (and user)

I want to return ALL 'Games' with 'MyPick' (doesn't matter if I picked
the game or not).  It would be nice to see the hasOne relationship
carry an "on" param that does the following ...

$this->Game->bindModel(array(
    'hasOne' => array(
        'MyPick' => array(
            'className' => 'PicksUsers', // NOT a habtm relationship,
btw
            'foreignKey' => 'game_id',
            'on' => "MyPick.user_id='1'",
            // 'conditions' => "PicksUsers.user_id='1'", // can't do
this because it only will return games I picked
        ),
    ),
));
$this->Game->findAll();

Result (sql)..
SELECT * FROM games ... LEFT JOIN picks_users As MyPick ON
(MyPick.game_id = Game.id AND MyPick.user_id='1') ...

As you can see, now all games will be returned ...
Should I open a ticket?


--~--~---------~--~----~------------~-------~--~----~
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