> This question pertains to using DBI with a MySQL database.....
> I use placeholders for all my queries (mainly for security). 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???
> For example, when I do the following:
> print $sql;
> It prints:
> UPDATE Customers SET ID=?
> When I need it to print:
> UPDATE Customers SET ID='example'
> I know that I could replace the placeholders myself... but then
> again... I need to log the ACTUAL query that was just executed... or
> attempted to be executed.
How about this: you can pack this into a subroutine, i.e.