in reply to DBIx::Class - shortcutting relationships [resolved]
many_to_many detailed in DBIx::Class::Relationship is what you want, I think. FWIW, it sounds like your data is set-up well. Refactoring the tables for this would be a mistake. Fake, untested code for your case–
{ package MyApp::Schema::Result::League; # ... __PACKAGE__->has_many( league_teams => "MyApp::Schema::Result::Lea +gueTeam", "league" ); __PACKAGE__->many_to_many( teams => "league_teams", "team" ); # ... } { package MyApp::Schema::Result::Team; __PACKAGE__->has_many( league_teams => "MyApp::Schema::Result::Lea +gueTeam", "team" ); __PACKAGE__->many_to_many( leagues => "league_teams", "league" ); # ... } { package MyApp::Schema::Result::LeagueTeam; # ... __PACKAGE__->belongs_to( league => "MyApp::Schema::Result::League" + ); __PACKAGE__->belongs_to( team => "MyApp::Schema::Result::Team" ); # ... }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: DBIx::Class - shortcutting relationships
by cLive ;-) (Prior) on Oct 04, 2012 at 18:48 UTC |