Subject: | Placeholders broken with mixed Integer/String usage |
I've had some problems using DBD::mysql 2.1020 with Apache::Session which took me a while to track down. The problem is that if a placeholder is "primed" using an integer-type value, and then later used with a string, the placeholder expansion is broken. For more details see:
http://marc.theaimsgroup.com/?l=msql-mysql-modules&m=103014432822561&w=2
For example if I run:
#!/usr/bin/perl
use DBD::mysql;
my $dbh = DBI->connect("dbi:mysql:test", undef, undef);
$dbh->do("DROP TABLE IF EXISTS test");
$dbh->do("CREATE TABLE test ( content varchar(255) )");
my $sql_str = "INSERT INTO test SET content = ?";
my $sth = $dbh->prepare($sql_str);
$sth->execute(1);
$sth->execute("foo");
I get
DBD::mysql::st execute failed: Unknown column 'foo' in 'field list' at dbd_mysql.pl line 9.
The workaround is to replace the first execute statement with
$sth->execute("1");
Please let me know if you would like a patch for the code, or a documentation patch to add this to the "Known Problems" section of the POD.
Thanks,
TJ