Edit report at https://bugs.php.net/bug.php?id=55335&edit=1
ID: 55335 Updated by: il...@php.net Reported by: jakob at revealit dot dk Summary: PDO query processing with postgres standard_conforming_strings and escape chars -Status: Open +Status: Bogus Type: Bug Package: PDO related Operating System: * PHP Version: 5.3.6 Block user comment: N Private report: N New Comment: Sorry, but your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php as this bug system is not the appropriate forum for asking support questions. Due to the volume of reports we can not explain in detail here why your report is not a bug. The support channels will be able to provide an explanation for you. Thank you for your interest in PHP. The issue is not with PHP but rather PostgreSQL's PQescapeStringConn function which is what PHP uses to escape to implement quote(). This function does not appear to be aware of the standard_conforming_strings setting and continues to use \ where '' should be used. Previous Comments: ------------------------------------------------------------------------ [2011-08-01 11:29:13] jakob at revealit dot dk Description: ------------ The test script below shows the point best. One thing to notice, is that this bug only happens when you have standard_conforming_strings set to "on" in your postgres.conf file. It seems like the fact that PHP uses '\' as escape char might be messing things up, sd $pdo->quote("\\") return '\' when standard_conforming_strings is set to "on" vs, '\\' when it's off. Test script: --------------- $pdo = new PDO($dns, $username, $password); $statement = $pdo->prepare("SELECT table.* FROM table table WHERE (column ILIKE :db_condition_placeholder_0 ESCAPE " . $pdo->quote("\\") . ") AND (column ILIKE :db_condition_placeholder_1 ESCAPE " . $pdo->quote("\\") . ");"); $statement->execute(array(':db_condition_placeholder_0' => 'test', ':db_condition_placeholder_1' => 'test')); Expected result: ---------------- No errors and query executed: Actual result: -------------- Error produced: Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: :db_condition_placeholder_1 in ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=55335&edit=1