Bug #74996 [Opn->Dup]: PDOStatement failed to bindValue with standard_conforming_strings (PostgreSQL)
Edit report at https://bugs.php.net/bug.php?id=74996&edit=1
ID: 74996
Updated by: cmb@php.net
Reported by: miloslav dot hula at gmail dot com
Summary: PDOStatement failed to bindValue with
standard_conforming_strings (PostgreSQL)
-Status: Open
+Status: Duplicate
Type: Bug
Package: PDO PgSQL
PHP Version: 7.1.7
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
This has the same root cause as bug #79276; since that other
ticket has already some discussion and an attached patch, I'm
closing this ticket. It should be noted though, that this likely
could be fixed on the driver level as well, in which case this
wouldn't be a duplicate. Still, in my opinion, it is a bug in PDO
core to cater to MySQL's idiosyncracies.
Previous Comments:
------------------------------------------------------------------------
[2017-07-27 10:46:01] miloslav dot hula at gmail dot com
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 this bug report at https://bugs.php.net/bug.php?id=74996&edit=1
Thread (2 messages)