DBD::mysql 3.001 - Question marks in strings mistaken for bind placeholders

DBD::mysql 3.001 - Question marks in strings mistaken for bind placeholders

am 21.07.2005 06:56:43 von Matthew Braid

Hi all,

After a recent port upgrade on one of our FreeBSD machines, I noticed that question marks inside strings were being erroneously picked up as bind placeholders, eg, this code (when the appropriate connection parameters are supplied and a table with specs of 'CREATE TABLE test (t1 varchar(255) not null, t2 varchar(255) not null)' has been created):

my $dbh = DBI->connect(...); # FILL ME IN!
my $query =
"INSERT INTO test (t1, t2) VALUES (?, " . $dbh->quote("?") . ")";
print $query, "\n";
my $sth = $dbh->prepare($query);
$sth->execute('Question Mark');
print "OK!\n";

results in:

INSERT INTO test (t1, t2) VALUES (?, '?')
DBD::mysql::st execute failed: called with 1 bind variables when 2 are needed

The previous version we had installed (2.9008) would do this query without problems (and since we have now rolled back the ports, continues to do so).

Is this a new feature of bind placeholders being allowed to exist inside strings (in which case $dbh->quote should quote it out of specialness) or is something broken here?

Ta,
MB


--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org