Masem hides his SQL statements by defining them elsewhere, whereas my problem is with the surrounding DBI code. Every time I want to look something up I have to do something like:
DBI provides a few methods such as selectall_arrayref or whatever... but these methods are not cached, and they only return a few data types (there is no selectall_hashref). What I would like to do is this:$sth=$dbh->prepare("select whatever from thetable where col=?"); $sth->execute($val); my @list; while(my $hashref=$sth->fetchrow_hashref) { push @list,$hashref; } $sth->finish; return \@list;
All the statements would be compiled with prepare_cached. Does anyone know off hand if any of those DBIx modules support this sort of thing?my $hashref=$dbh->getall_hashref("select * from abc where col=?",$val) +; my $arrayref=$dbh->getrow_arrayref("select * from abc where col=?",$va +l); etc...
In reply to Re: Leashing DBI
by entropy
in thread Leashing DBI
by billyak
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |