Bug #74996 [NEW]: PDOStatement failed to bindValue with standard_conforming_strings (PostgreSQL)

From: Date: Thu, 27 Jul 2017 10:46:06 +0000
Subject: Bug #74996 [NEW]: PDOStatement failed to bindValue with standard_conforming_strings (PostgreSQL)
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-210367@lists.php.net to get a copy of this message
From: miloslav dot hula at gmail dot com Operating system: PHP version: 7.1.7 Package: PDO related Bug Type: Bug Bug description:PDOStatement failed to bindValue with standard_conforming_strings (PostgreSQL) Description: ------------ PDOStatement failed to bindValue with standard_conforming_strings=on. Setting PDO::ATTR_EMULATE_PREPARES true/false is irrelevant. Seems to me as a bug during ? replacing by the $1 or by the value in emulated prepares mode. In the PostgreSQL log is message: ERROR: syntax error at or near "," at character 51 STATEMENT: INSERT INTO test (col1, col2, col3) VALUES ('\', ?, ' ') Test script: --------------- $pdo = new PDO('pgsql:host=localhost;dbname=test', 'test', 'test'); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $pdo->query('SET standard_conforming_strings TO on'); $stmt = $pdo->prepare("INSERT INTO test (col1, col2, col3) VALUES ('\\', ?, ' ')"); $stmt->bindValue(1, 'x', PDO::PARAM_STR); $stmt->execute(); # following are successful $stmt = $pdo->prepare("INSERT INTO test (col1, col2, col3) VALUES ('\\ ', ?, ' ')"); $stmt = $pdo->prepare("INSERT INTO test (col1, col2) VALUES ('\\', ?)"); Actual result: -------------- Fatal error: Uncaught PDOException: SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "," LINE 1: INSERT INTO test (col1, col2, col3) VALUES ('\', ?, ' ') ^ in .../test2.php:11 -- Edit bug report at https://bugs.php.net/bug.php?id=74996&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=74996&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=74996&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=74996&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=74996&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=74996&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=74996&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=74996&r=needscript Try newer version: https://bugs.php.net/fix.php?id=74996&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=74996&r=support Expected behavior: https://bugs.php.net/fix.php?id=74996&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=74996&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=74996&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=74996&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74996&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=74996&r=dst IIS Stability: https://bugs.php.net/fix.php?id=74996&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=74996&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=74996&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=74996&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=74996&r=mysqlcfg

« previous php.bugs (#210367) next »