[Cologne-pm] DBIx::Class joins?!?

Tobias Kremer list at funkreich.de
Thu Jul 5 00:29:34 PDT 2007


Hi Michael,

versuch das mal:

> ---------- Schema/Cd.pm ----------
> package Schema::Cd;
> __PACKAGE__->has_many( cd_genre => 'Schema::CdGenre', 'genre' );
> __PACKAGE__->many_to_many( 'cds' => 'cd_genre', 'cd' );

__PACKAGE__->has_many( cd_genre => 'Schema::CdGenre', 'cd' );
__PACKAGE__->many_to_many( 'genres' => 'cd_genre', 'genre' );


> ---------- Schema/Genre.pm ----------
> __PACKAGE__->has_many( cd_genre => 'Schema::CdGenre', 'cd' );
> __PACKAGE__->many_to_many( 'genres' => 'cd_genre', 'genre' );

__PACKAGE__->has_many( cd_genre => 'Schema::CdGenre', 'genre' );
__PACKAGE__->many_to_many( 'cds' => 'cd_genre', 'cd' );


> ---------- dbix ----------
# Alle CDs im Genre "Techno":
my $genre = $schema->resultset( 'Genre' )->find( { name => 'Techno' } );
my @cds = $genre->cds();
print $_->name for @cds;


Hoffe, es funktioniert und hilft Dir weiter!

--Tobias


More information about the Cologne-pm mailing list