Subject: | Escaped single quotes in a literal values break variable binding |
The following code:
$dbh->selectall_arrayref("
SELECT * FROM people
WHERE last_name = 'O\'Brian' AND age = ?
", undef, 25);
dies with "DBD::mysql::db selectall_arrayref failed: called with 1
bind variables when 0 are needed". I know I could have just bound both
variables, but this is a simplified example. The actual SQL is dynamic
and the reasons for not using binding for some values are legitimate.