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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
44 - 7 = ?
Subscribe to this entry?

 
 [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-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 19:01:28 2024 UTC