Don't forget about prepare_cached(). This can really help under mod_perl.
This code will do little more than suck up more memory:
for my $val(@values) { $val = $dbh->quote($val); my $sth = $dbh->prepare_cached( "UPDATE foo SET bar=7 WHERE baz=$val" ); $sth->execute(); }
This code takes up a little more memory, but also avoids having to re-prepare what is really the same statement with different input:
for my $val(@values) { my $sth = $dbh->prepare_cached( "UPDATE foo SET bar=7 WHERE baz=?" ); $sth->execute($val); }
----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer
: () { :|:& };:
Note: All code is untested, unless otherwise stated
In reply to Re: Use Placeholders. For SECURITY and (sometimes) for PERFORMANCE
by hardburn
in thread Use Placeholders. For SECURITY and (sometimes) for PERFORMANCE
by jZed
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |