locked_user sundialsvc4 has asked for the wisdom of the Perl Monks concerning the following question:
I have (courtesy of DBIx::Class::Loader a schema which describes (correctly) the following database structure:
TSeminar --+ +--TMarket +--TProgram--TFees
In other words, in TSeminar.pm I see:
and in TProgram.pm:__PACKAGE__->belongs_to( "marketcode", "FOO::Schema::Scheme::TMarket", { citycode => "marketcode" }, ); __PACKAGE__->belongs_to( "programcode", "FOO::Schema::Scheme::TProgram", { programcode => "programcode" }, );
__PACKAGE__->belongs_to( "progfee", "FOO::Schema::Scheme::TFees", { feeid => "progfee" }, );
A simple two-way join that considers only the leftmost three tables works:
my $rs= $c->schema->resultset("TSeminar")->search( { 'semcode' => $code }, { "join" => ['programcode', 'marketcode'], "prefetch" => [qw/programcode marketcode/], "order_by" => [qw/semcode/], "rows" => 30});
Now, I want to apply the example from DBIx::Class::Manual::Joining:
Or combine the two:
join => { room => [ 'chair', { table => 'leg' } ]
I cannot, for the life of me, make it work! Here's what I am trying:
join => [ 'marketcode', {'programcode'=>'progfee'} ]
I emphasized the two words because it seems to me that it's looking for progfee, which (I am trying to tell it...) is accessed from TProgram not TSeminar. I think that I am following the cookbook example rather strenuously, although I am fighting the fact that ... :-< ... the POD author resorted to “trying to be funny” instead of trying to be clear. Instead of sticking to the actual example he had previously been using in the document, he wandered off into the land of the completely irrelevant.
I piece-together from his example that he is searching for a (single...) related room from whence you can find a chair and a table that has legs. Well... I'm trying to create the case where the base-table of the query is room.
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (Yet Another) DBIx::Class Joins question
by pileofrogs (Priest) on Jan 28, 2009 at 23:23 UTC | |
|
Re: (Yet Another) DBIx::Class Joins question
by dragonchild (Archbishop) on Feb 03, 2009 at 18:17 UTC | |
by locked_user sundialsvc4 (Abbot) on Feb 04, 2009 at 00:16 UTC |