|  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
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
 [2009-01-20 19:03 UTC] rcrowell at nextjump dot com
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 +");

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.


Add a Patch

Pull Requests

Add a Pull Request


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]
-Package: PDO_DBLIB +Package: PDO DBlib
 [2017-04-10 21:15 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: adambaratz
 [2017-04-10 21:15 UTC]
This issue isn't present in the latest version of PDO.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Thu Jun 17 04:01:23 2021 UTC