[Dbix-class] Help with many to many relationship

RAPPAZ Francois francois.rappaz at unifr.ch
Tue Apr 1 15:09:50 GMT 2014


Hi

I have two tables Abo (primary key: noabt) and Jrn (primary key: nofm) join  by a linking table jrnabt (primary keys: nofm, noabt)

I have defined the relationship as

Abo.pm
 __PACKAGE__->has_many( abojrnabt => 'Dbc::Jrnabt',  {'foreign.noabt' => 'self.noabt'});

Jrn.pm
 __PACKAGE__->has_many(jrnjrnabt => 'Dbc::Jrnabt',  {'foreign.nofm' => 'self.nofm'});

Jrnabt.pm

__PACKAGE__->belongs_to(jrnabtjrn => 'Dbc::Jrn',  {'foreign.nofm' => 'self.nofm'});
__PACKAGE__->belongs_to(jrnabtabo => 'Dbc::Abo',  {'foreign.noabt' => 'self.noabt'});

When I try
my $rs = $schema->resultset('Abo')->search_rs({'abojrnabt.nofm' => '1'}, {join => 'abojrnabt'});

I got 
DBIx::Class::Schema::source(): Can't find source for Dbc::Jrnabt at U:\docs\perl\dokpe_i01_dbc\testdbc.pl line 62

What am I missing ?

Thanks

François Rappaz

Centre de documentation de la Faculté des Sciences Université de Fribourg DokPe - Dokumentationszentrum der Naturwissenschaftlichen Fakultät Universität Freiburg Pérolles CH-1700 Fribourg Switzerland http://www.unifr.ch/dokpe/
Tel.: 41 (0)26 300 92 60
Fax.: 41 (0)26 300 97 30





More information about the DBIx-Class mailing list