php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41215 setAttribute return code reversed
Submitted: 2007-04-27 17:09 UTC Modified: 2007-04-29 14:47 UTC
From: jerry at gii dot co dot jp Assigned: iliaa (profile)
Status: Closed Package: PDO related
PHP Version: 5.2.1 OS: WinXP Home SP2
Private report: No CVE-ID: None
 [2007-04-27 17:09 UTC] jerry at gii dot co dot jp
Description:
------------
dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION)

returns FALSE on success and TRUE on failure. This is the reverse of the documentation (and counter-intuitive).

The data base server is MySQL 4.1.21-standard running on CentOS 3.

Reproduce code:
---------------
<?php
               $dbh = new PDO("mysql:host=$db_hostname;dbname=$db_name", "$db_user_name",
                        "$db_user_pass");
$r_code = $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$errmode = $dbh->getAttribute(PDO::ATTR_ERRMODE);
echo ($r_code ? "TRUE" : "FALSE") . " | " . $errmode;
?>


Expected result:
----------------
It should echo

TRUE | 2

Actual result:
--------------
FALSE | 2

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-04-27 17:11 UTC] jerry at gii dot co dot jp
I purposely didn't show the values of the parameters for the opening of the data base, but trust me that they are correct.
 [2007-04-29 14:47 UTC] iliaa@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 15:01:30 2024 UTC