in reply to Use Placeholders. For SECURITY and (sometimes) for PERFORMANCE
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Use Placeholders. For SECURITY and (sometimes) for PERFORMANCE
by mpeppler (Vicar) on Nov 14, 2003 at 22:38 UTC | |
by hardburn (Abbot) on Nov 17, 2003 at 14:34 UTC |