ID: 48314 Updated by: [email protected] Reported By: [email protected] Status: Open Bug Type: PDO related Operating System: Windows PHP Version: 5.2.9 New Comment:
Occasionally I am tempted to bogus any PDO MYSQL character set bug report I see. SET NAMES won't be recognized by the client and the wrong character set will be used for escaping. Adding a DSN option to specify the character set upon connect and setting it properly through the C API may be only five lines of code. But even if that would be implemented we would still have the PDO PS emulation as a potential pitfall. PDO will call the driver for escaping bound values and the driver will properly escape the values. But the PDO SQL parser itself won't care much about the current character set when searching for placeholders. Previous Comments: ------------------------------------------------------------------------ [2009-09-29 21:41:34] [email protected] Well, you should not use SET NAMES. It will not change the charset used for quoting. Currently there is no way to change the charset via an API call. Try ext/mysqli... ------------------------------------------------------------------------ [2009-05-18 13:45:30] [email protected] Same result. ------------------------------------------------------------------------ [2009-05-18 13:43:31] [email protected] Try also disabling PDO::ATTR_EMULATE_PREPARES. PHP 5.3 got some improvements/fixes with PDO_mysql (due to mysqlnd work) not sure if some parts can be backported. ------------------------------------------------------------------------ [2009-05-18 13:25:17] [email protected] 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 this bug report at http://bugs.php.net/?id=48314&edit=1
