Doctrine 1.2 - Many-to-Many with extra fields
I have defined four MySQL tables:
accounts
games
games_to_accounts
status
A typical many-to-many relationship involving accounts, games, and games_to_accounts is in place. However the games_to_accounts table has an extra field, status_id, which defines how the associated account is treating the game (playing, for sale, etc).
I can retrieve an account's games per usual just fine:
$account->Games
In the GameAccount base model I've defined the hasOne relationship with the Status model like this:
$this->hasOne('Default_Model_Status as Status', array(
'local' => 'status_id',
'foreign' => 'id'));
However when iterating over these games why in the world can't I retrieve the status? Example:
foreach ($account->Games as $game)
{
echo $game->Status->name;
}
Surely Doctrine supports the ability to add extra fields to an association table? Any help much appreciated, as I've looked everywhere for an answer yet am turning up no开发者_Python百科thing on what strikes me as a commonplace issue.
Jason
I sorted this out, was a simple oversight on my part.
精彩评论