in reply to Test if string is already quote()'d?
DBI's quote method is one of those things that you should almost never use. Instead of saying something like this:
my $name = $dbh->quote("widget"); $dbh->do("delete from products where name = $name");
It's much safer to use placeholders like this:
$dbh->do("delete from products where name = ?", $name);
In this case, your function would accept only unquoted strings, but it's a better solution in the long run.
Update Sorry, that should have been:
$dbh->do("delete from products where name = ?", undef, $name);
The do method accepts an optional hashref of attributes as its second parameter.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Test if string is already quote()'d?
by Seumas (Curate) on Jun 14, 2003 at 22:57 UTC | |
by jeffa (Bishop) on Jun 14, 2003 at 23:40 UTC | |
by Seumas (Curate) on Jun 17, 2003 at 22:10 UTC |