Edit report at http://bugs.php.net/bug.php?id=53185&edit=1
ID: 53185
Comment by: alexc223 at googlemail dot com
Reported by: alexc223 at googlemail dot com
Summary: PDO_MYSQL constructor, PHP warning w/ Exception
error mode
Status: Assigned
Type: Bug
Package: PDO related
Operating System: Linux
PHP Version: 5.3.3
Assigned To: mysql
Block user comment: N
Private report: N
New Comment:
Maybe there needs to be a way for it to know? Either way, it's highly
annoying
since there is very little ways to handle it.
Previous Comments:
------------------------------------------------------------------------
[2010-11-02 22:12:57] [email protected]
The warning come from mysqlnd_connect() call that nothing knows about
such PDO feature...
------------------------------------------------------------------------
[2010-10-27 17:17:23] alexc223 at googlemail dot com
Description:
------------
A PHP warning is generated even though I've explicitly set the PDO error
mode to
use exceptions. This warning occurs when the MySQL socket does not exist
(for
example, if MySQL is not yet started).
This makes it quite impossible to handle.
Test script:
---------------
<?php
try {
$pdo = new Pdo( 'mysql:host=localhost;dbname=test', 'user',
'pass', array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION) );
} catch ( PDOException $e ) {
echo 'unable to connect';
}
?>
Expected result:
----------------
unable to connect
Actual result:
--------------
Warning: PDO::__construct(): [2002] No such file or directory (trying to
connect
via unix:///var/run/mysqld/mysqld.sock) in php shell code on line 2
unable to connect
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=53185&edit=1