[Dbix-class] DBIx::Class::Relationship issue
Michele Beltrame
mb at italpro.net
Tue Mar 20 13:30:02 GMT 2007
Hi!
> while( my $artist = $rs->next)
> {
> print $artist->cds->title . "\n\n";
> }
The "cds" relations is has_many, so you'll probably want to do this to display
all CD title of all artists:
while( my $artist = $rs->next) {
my $cds = $artist->cds;
while ( my $cd = $cds->next ) {
print $cd->title . "\n\n";
}
}
If you only expect one CD per artist, you can do as follows:
while( my $artist = $rs->next) {
print $artist->cds->first->title . "\n\n";
}
Michele.
More information about the Dbix-class
mailing list