From: [email protected]
Operating system: Windows
PHP version: 5.2.9
PHP Bug Type: PDO related
Bug description: PDO_MySQL doesn't use prepared statements
Description:
------------
It seems that PDO_MySQL doesn't use prepared statements even with disabled
PDO::MYSQL_ATTR_DIRECT_QUERY. If the prepared statements would by used then
the binary data passed in the example wouldn't cause a parse error.
MySQL version: 5.1.26
Reproduce code:
---------------
<?php
$pdo = new PDO("mysql:host=localhost", "ODBC", "");
$pdo->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, false);
$pdo->exec("SET NAMES gbk");
$stmt = $pdo->prepare("SELECT ?");
$stmt->execute(array(chr(0xbf) . chr(0x27)));
print_r($stmt->errorInfo());
?>
Expected result:
----------------
Array
(
[0] => 00000
)
Actual result:
--------------
Array
(
[0] => 42000
[1] => 1064
[2] => You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near
''¿\''' at line 1
)
--
Edit bug report at http://bugs.php.net/?id=48314&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=48314&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=48314&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=48314&r=trysnapshot60
Fixed in CVS:
http://bugs.php.net/fix.php?id=48314&r=fixedcvs
Fixed in CVS and need be documented:
http://bugs.php.net/fix.php?id=48314&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=48314&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=48314&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=48314&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=48314&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=48314&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=48314&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=48314&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=48314&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=48314&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=48314&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=48314&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=48314&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=48314&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=48314&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=48314&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=48314&r=mysqlcfg