|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2017-10-24 08:34 UTC] kalle@php.net
-Package: PDO related
+Package: PDO PgSQL
[2020-11-03 18:21 UTC] cmb@php.net
-Status: Open
+Status: Duplicate
-Assigned To:
+Assigned To: cmb
[2020-11-03 18:21 UTC] cmb@php.net
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 01:00:01 2025 UTC |
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