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
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: 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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Wed Jan 15 10:01:29 2025 UTC