php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68572 [PHP Modules] apc bcmath bz2 calendar Core ctype curl date dba dom ereg exif fi
Submitted: 2014-12-09 06:50 UTC Modified: 2015-02-03 10:21 UTC
From: me at free6k dot ru Assigned:
Status: Not a bug Package: PDO PgSQL
PHP Version: 5.4.35 OS: Debian 7.7 Wheezy
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: me at free6k dot ru
New email:
PHP Version: OS:

 

 [2014-12-09 06:50 UTC] me at free6k dot ru
Description:
------------
I have the following problem with binding params in pdo for sql requests

Test script:
---------------
$timezone = 'Asia/Jakarta';
$statement = $pdo->prepare('SET TIME ZONE :timezone');
$statement->execute([':timezone'=>$timezone]);

Actual result:
--------------
PDOException
SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "$1"
LINE 1: SET TIME ZONE $1

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-02-03 10:21 UTC] mbeccati@php.net
-Status: Open +Status: Not a bug
 [2015-02-03 10:21 UTC] mbeccati@php.net
Thank you for taking the time to write to us, but this is not
a bug. 

Postgres doesn't support preparing a SET TIME ZONE query: http://www.postgresql.org/docs/9.4/static/sql-prepare.html

(And PDO_pgsql will try to prepare it, since you are using a parameter)

You could either generate the query manually (using PDO::quote) or temporarily using: $pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 10:01:29 2024 UTC