cLive ;-) has asked for the wisdom of the Perl Monks concerning the following question:
UPDATE: I was being brain dead, but leaving this question up because I see no way to delete it...
If I have 3 tables (league, team and league_team), with the following relationships:
league has one to many league_team
team has one to many league_team
with league,team being the PK on the league_team table.
What I want to build is so the following will work (say) for a league):
while (my $team = $league->teams->next ) { ... }
With my current relationship across the three tables though, I have to use this:
while (my $team_league = $league->team_league->next ) { my $team = $team_league->team; ... }
I'm guessing also, that there's going to need to be an implicit create on the league_team entry wrapped in the term:
$league->team->create()I can easily hack the interface I want, but I'm assuming that there is a correct way to do this in DBIx::Class. What is it? Anyone got a working example I can look at for inspiration?
Oh, I found this module, but I'm not quite getting it, if that is indeed the solution.
Note, refactoring the tables is not something I have access to right now.
Edit: I think I've found the term I was looking for - relationship_bridge. Now I just need to find an example, heh. The hardest part of any quest is working out what you're looking for, heh
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: DBIx::Class - shortcutting relationships
by Your Mother (Archbishop) on Oct 04, 2012 at 18:42 UTC | |
by cLive ;-) (Prior) on Oct 04, 2012 at 18:48 UTC |