in reply to Re^2: fetchrow/all vs selectrow/all
in thread fetchrow/all vs selectrow/all
Note that you should probably use placeholders. It’s so easy with DBI that there’s rarely a reason not to.
my $stmt = "SELECT * FROM mytable WHERE id = ?"; my $sth = $dbh->prepare( $stmt ); $sth->execute( $myid ); my $results = $sth->fetchall_arrayref( {} ); # or my $stmt = "SELECT * FROM mytable WHERE id = ?"; my $results = $dbh->selectall_arrayref( $stmt, undef, $myid );
Then you can also further optimise the first case by saying
my $sth = $dbh->prepare_cached( $stmt );
In that case, because the placeholder-adorned query is always the same, you might even end up preparing the statement only once during your entire runtime.
Makeshifts last the longest.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: fetchrow/all vs selectrow/all
by bradcathey (Prior) on Nov 26, 2005 at 01:28 UTC | |
by Aristotle (Chancellor) on Nov 26, 2005 at 01:54 UTC |