in reply to Is this Bad form? (DBI)
I like to use a factory to ask for a DBI handle. Like so.use strict; my $dbh = DBI->connect(XXXX); runSomeQueries(); $dbh->disconnect(); sub runSomeQueries { my $query = "select * from table"; my $sth = $dbh->prepare($query); if ( $sth->execute() ) while (my $data = $sth->fetchrow_hashref ) { runSomeSubQueries(some$$hash{ItemID}); } } sub runSomeSubQueries { my $itemID = shift; my $query = "select * from detail_table where ItemID = ?"; my $sth = $dbh->prepare($query); $sth->execute($itemID); }
-HTH
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Is this Bad form? (DBI)
by Grygonos (Chaplain) on Aug 25, 2003 at 16:48 UTC | |
by LanceDeeply (Chaplain) on Aug 25, 2003 at 19:17 UTC | |
by zigdon (Deacon) on Aug 25, 2003 at 17:07 UTC |