Yii Relations()

Hello, I need help.

I have stage, match, game models. Stage can have many matches, and match have to belongs to only one stage. And match can have many games, game have to belongs to only one match. So the stage have many games.

the realtions I wrote are:

For stage

matches=>array(self::HAS_MANY, 'Stage','stageID'),

For match

games=>array(self::HAS_MANY, 'Match', 'matchID'),

Since stage has many games, is there any to access games from stage model.

The game model has date attribute which indicates when the game is held. The thing I need to do is that I need to find game whose date is close to current time from the all games of stage.

Sorry for my poor english.

take a look at the guide this is coverd nicely in guide here


Thank you.