Hi. First, can anybody recommend a few Websites that explain CakePHP associations and provide tutorials and examples? I have read the manual and a couple other Websites, but I am still having problems understanding the concepts.
Second, I need help with figuring out the association between two models, Team and Game. They are part of a basketball league Website I am building. I believe the appropriate association between the models is hasAndBelongsToMany, but I could be wrong. I set the $hasAndBelongsToMany variable in both models (see listing below) and I also setup the teams_games database which contains the fields team_id and game_id. In my controller I call $this->set('gamesdata', $this->Game- >findAll()), I don't get anything in the Team array (see results listing below) and I get an error when I try to access the teams data in my view. Can anyone tell me what I'm doing wrong. Please let me know if more information is needed. RESULTS ======= Array ( [0] => Array ( [Game] => Array ( [id] => 3943je [season_id] => fsdrfe8l [gamedatetime] => 2007-06-05 11:05:00 [home] => jsnd73f [visitor] => 439jfdks [homescore] => 4 [visitorscore] => 800 [winner] => [created] => 0000-00-00 00:00:00 [modified] => 0000-00-00 00:00:00 ) [Season] => Array ( [id] => [season_type_id] => [name] => [startdate] => [created] => [modified] => ) [Team] => Array ( ) ) ) GAME MODEL =========== class Game extends AppModel { var $name = 'Game'; var $belongsTo = array('Season' =>array('className' => 'Season', 'conditions' => '', 'order' => '', 'foreignKey' => 'season_id')); var $hasAndBelongsToMany = array('Team' =>array('className' => 'Team', 'joinTable' => 'teams_games', 'foreignKey' => 'game_id', 'associationForeignKey' => 'team_id')); } TEAM MODEL =========== class Team extends AppModel { var $name = 'Team'; var $belongsTo = array('City' =>array('className' => 'City', 'conditions' => '', 'order' => '', 'foreignKey' => 'city_id' )); var $hasAndBelongsToMany = array('Game' =>array('className' => 'Game', 'joinTable' => 'teams_games', 'foreignKey' => 'team_id', 'associationForeignKey' => 'game_id')); } --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---