Hello,
> I have a "matches" table that consist of a home_team and an away_team
> column. I also have a teams table with the team information so
> home_team and away_team are foreign keys referring to the particular
> id of teams.
>
> Unfortunately I can't seem to configure this with cakephp (the naming
> conventions would suggest to make a home_teams table and an away_teams
> table but that's ridiculous, data duplication, I guess). Could someone
> help me setting up the associations? $hasMany? $belongsTo?
You are right, no need for two tables. Just setup two 'belongsTo' relationships.
var $belongsTo = array(
'HomeTeam' => array(
'className' => 'Team',
'foreignKey' => 'home_team'
),
'AwayTeam' => array(
'className' => 'Team',
'foreignKey' => 'away_team'
)
);
Works?
Regards,
Piotr
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---