Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: DBIx::Class - shortcutting relationships

by Your Mother (Chancellor)
on Oct 04, 2012 at 18:42 UTC ( #997289=note: print w/ replies, xml ) Need Help??


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" ); # ... }


Comment on Re: DBIx::Class - shortcutting relationships
Select or Download Code
Re^2: DBIx::Class - shortcutting relationships
by cLive ;-) (Parson) on Oct 04, 2012 at 18:48 UTC
    Yeah, thanks. About 10 minutes after I posted it I worked it out. I was so wrapped up in a detail that I didn't think to look up many to many. Heh.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://997289]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (8)
As of 2015-07-05 06:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls