phildeman has asked for the wisdom of the Perl Monks concerning the following question:
Hi All,
Can variables be used in place of column names when looping through DBIx::Class array of objects.
For example:
my @db_colnames = ('lastname','firstname','middlename'); my @rows = $schema->resultset( 'myTable' )->search({}, {order_by => [qw +/ lastname firstname middlename /] } ); foreach my $row (@rows) { foreach my $col (@db_colnames) { print $row->$col ."\t"; } print "\n"; }
No value printed. However, when I used the actual column name to retrieve the data, it worked fine. For example:
. . print $row->lastname . "\t" . $row->firstname . "\t" . $row->middlenam +e . "\t"; print "\n"; . .
Thanks for your help.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: DBIx::Class Looping thru resultset
by Your Mother (Archbishop) on Apr 29, 2016 at 20:29 UTC | |
Re: DBIx::Class Looping thru resultset
by Myrddin Wyllt (Hermit) on Apr 30, 2016 at 13:34 UTC | |
Re: DBIx::Class Looping thru resultset
by Ovid (Cardinal) on May 02, 2016 at 06:00 UTC |