Skip Menu |
 

This queue is for tickets about the DBD-mysql CPAN distribution.

Report information
The Basics
Id: 17466
Status: rejected
Priority: 0/
Queue: DBD-mysql

People
Owner: Nobody in particular
Requestors: me [...] privacy.net
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 3.0002_5
Fixed in: (no value)



Subject: Escaped single quotes in a literal values break variable binding
Download (untitled) / with headers
text/plain 417b
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.
Download (untitled) / with headers
text/plain 795b
On Fri Feb 03 10:54:45 2006, guest wrote: Show quoted text
> 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.
This is not a bug in the driver, it is a bug in your code. You need to escape the escape character before the ' to get the query you want, because it is being seen as an escaped character in the double-quoted string. You could also escape the single quote by using two single quotes. Thanks for the report.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.