in reply to Leashing DBI
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...
|
---|
Replies are listed 'Best First'. | |
---|---|
(jeffa) 2Re: Leashing DBI
by jeffa (Bishop) on Jun 27, 2001 at 08:39 UTC | |
Re: Re: Leashing DBI
by buckaduck (Chaplain) on Jun 27, 2001 at 22:14 UTC |