php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74996 PDOStatement failed to bindValue with standard_conforming_strings (PostgreSQL)
Submitted: 2017-07-27 10:46 UTC Modified: 2017-10-24 08:34 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: miloslav dot hula at gmail dot com Assigned:
Status: Open Package: PDO PgSQL
PHP Version: 7.1.7 OS:
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2017-07-27 10:46 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-10-24 08:34 UTC] kalle@php.net
-Package: PDO related +Package: PDO PgSQL
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 08:01:25 2019 UTC