Re: Help With Placeholders



PerlGoon wrote:

The
problem I have is that I need to be able to print the actual queries
my code runs into a log.... with the placeholders replaced.

For example, consider the following:

my $id = "example";
my $sql = "UPDATE Customers SET ID=?";
my $query = $db->prepare($sql);
$query->execute($id);

How do I print the ACTUAL query that was run into a log file.... with
the placeholders replaced???

You can replace each placeholder in the SQL statement with a value
calculated as $dbh->quote($_) for the next bind value.

You might be able to do that by overriding execute and putting the
logging in that method, though I bet it will not be easy: DBI is a very
hard module to subclass.

--
Bart.
.