php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58514 PDO attributes ignored when passed in constructor
Submitted: 2009-01-20 19:03 UTC Modified: 2017-04-10 21:15 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: rcrowell at nextjump dot com Assigned: adambaratz (profile)
Status: Closed Package: PDO DBlib
PHP Version: 5.1.6 OS: RedHat el5
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: rcrowell at nextjump dot com
New email:
PHP Version: OS:

 

 [2009-01-20 19:03 UTC] rcrowell at nextjump dot com
Description:
------------
The PDO driver ignores the ATTR_ERRMODE attribute when it is 
passed in via the constructor.  Exceptions are thrown 
correctly when attributes are set via setAttribute().




Reproduce code:
---------------
$connection = new PDO($url, $username, $password, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
$connection->prepare("SELECT 10 +");
$query->execute();

Expected result:
----------------
Exception thrown.

Fatal error: Uncaught exception 'PDOException' with message 
'SQLSTATE[HY000]: General error: 20018 Incorrect syntax near 
'+'. [20018] (severity 5) [(null)]'

Actual result:
--------------
No exception thrown.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-01-20 20:05 UTC] rcrowell at nextjump dot com
This seems to impact all attributes, not just ATTR_ERRMODE.  I wrote code to set ATTR_CASE and the same behavior was noted (attributes aren't set when passed into the constructor, but are set when setAttribute is used).
 [2017-04-01 21:24 UTC] tpunt@php.net
-Package: PDO_DBLIB +Package: PDO DBlib
 [2017-04-10 21:15 UTC] adambaratz@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: adambaratz
 [2017-04-10 21:15 UTC] adambaratz@php.net
This issue isn't present in the latest version of PDO.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Mon Nov 30 20:01:27 2020 UTC