Yii Framework Forum: Soccer League Model - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Soccer League Model Player <-> Team relations Rate Topic: -----

#1 User is offline   thevenin 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 17-January 13

Posted 17 January 2013 - 02:24 PM

Hi,

I have 2 tables in a database:

Player:
-id
-first_name
-last_name
-team_id  //references Team.id


Team:
-id
-name
-captain_id  //references Player.id



I have created the following relations:

in Player model:

'team' => array(self:BELONGS_TO, 'Team', 'team_id');


in Team model:

'players' => array(self::HAS_MANY, 'Player', 'team_id'),
'captain' => array(self::BELONGS_TO, 'Player', 'captain_id'),


Could someone more experienced look at it and tell me if this is the correct configuration please?

Thank you.
0

#2 User is offline   Keith 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 868
  • Joined: 04-March 10
  • Location:UK

Posted 17 January 2013 - 03:10 PM

That looks fine to me.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users