Doc #77414 [NEW]: PDO __construct does not thrown an exception by default
| From: | admin at torntech dot com | Date: | Sat, 05 Jan 2019 19:48:36 +0000 |
| Subject: | Doc #77414 [NEW]: PDO __construct does not thrown an exception by default | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-16297@lists.php.net to get a copy of this message | ||
From: admin at torntech dot com
Operating system: n/a
PHP version: Irrelevant
Package: Documentation problem
Bug Type: Documentation Problem
Bug description:PDO __construct does not thrown an exception by default
Description:
------------
---
From manual page: https://php.net/pdo.construct
---
The description of Errors/Exceptions states "PDO::__construct() throws a
PDOException if the attempt to connect to the requested database
fails."
However the default PDO::ATTR_ERRMODE for PDO is PDO::ERRMODE_SILENT,
which requires the use of PDO::errorInfo() or PDO::errorCode() and does
not throw an exception as indicated
The documentation should include information about the PDO::ATTR_ERRMODE
attribute being set to PDO::ERRMODE_SLIENT by default and that an
exception is thrown only when the PDO::ATTR_ERRMODE attribute is set to
PDO::ERRMODE_EXCEPTION.
Test script:
---------------
new PDO ("mysql:localhost; dbname=test", "root", "");
//invalid DSN usage
Expected result:
----------------
An exception to be thrown
Actual result:
--------------
No Exception is thrown by default due to PDO::ERRMODE_SLIENT
--
Edit bug report at https://bugs.php.net/bug.php?id=77414&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77414&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77414&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77414&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=77414&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=77414&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=77414&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=77414&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=77414&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=77414&r=support
Expected behavior: https://bugs.php.net/fix.php?id=77414&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=77414&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=77414&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=77414&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77414&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=77414&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=77414&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=77414&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=77414&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=77414&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=77414&r=mysqlcfg