[Dbix-class] Help with many to many relationship

Hailin Hu i at h2l.name
Wed Apr 2 02:13:45 GMT 2014


Show up the folder structure and the actual package names.

On Wed, Apr 2, 2014 at 12:09 AM, RAPPAZ Francois
<francois.rappaz at unifr.ch> wrote:
> 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
>
>
>
> _______________________________________________
> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk



More information about the DBIx-Class mailing list