in reply to prepare statement within DBI
However, you could push the actual prepare/execute/fetch loop into a subroutine which would avoid the duplicated code (minimal and simplistic implementation):
Michaelmy $row1 = fetch_count($dbh, "table_one"); my $row2 = fetch_count($dbh, "table_two"); print "$row1, $row2\n"; sub fetch_count { my $dbh = shift; my $table = shift; my $sth = $dbh->prepare("select count(*) from $table"); $sth->execute; my $row = $sth->fetch_arrayref; return $row->[0]; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: prepare statement within DBI
by Smylers (Pilgrim) on Aug 26, 2004 at 14:27 UTC |