Is there a CPAN module out there that implements something like
bind_hash() from this article:
http://www.perl.com/pub/a/2001/03/dbiokay.html
My searches aren't coming up with anything.
Basically I'm looking for something like this snippet:
@results{@fields} = ();
$sth->bind_columns(map { \$results{$_} } @fields);
wrapped in a nice little interface.
Thanks,
-Todd
Just an unrelated tip: the above can be done a bit more idiomatically (and
probably a teeny bit faster) like this:
$sth->bind_columns(\@results{@fields});
-John
Hi all,
Is there a CPAN module out there that implements something like
bind_hash() from this article:
http://www.perl.com/pub/a/2001/03/dbiokay.html
My searches aren't coming up with anything.
Basically I'm looking for something like this snippet:
@results{@fields} = ();
$sth->bind_columns(map { \$results{$_} } @fields);
wrapped in a nice little interface.
Thanks,
-Todd
Have you looked at fetchrow_hashref or fetchall_hashref?
jwm
Which is very like the example in the DBI docs for the bind_columns method:
$sth->execute;
my %row;
$sth->bind_columns( \( @row{ @{$sth->{NAME_lc} } } ));
while ($sth->fetch) {
print "$row{region}: $row{sales}\n";
}
I hope you'll agree, Todd, that there's no need for an extra module.
CPAN has more than enough DBI helper/wrapper modules already.
Tim.
Thanks for setting me straight.
-Todd