From: mjsabby at gmail dot com
Operating system: Fedora Core 5
PHP version: 5.1.6
PHP Bug Type: PDO related
Bug description: Invalid DSN doesn't raise exception, connects to server,
doesn't select DB
Description:
------------
After looking closely at the previous bug, Bug #38736, which I filed, I
realized I had an incorrectly formatted DSN string.
'mysql:localhost;dbname=xxx'
The above DSN, doesn't throw an exception. It instead goes aheads and
connects to the MySQL server, but doesn't end up selecting the database.
I found this out (in reference to the previous bug) after I set the PDO
mode to throw exceptions at everything to analyze what really was going
wrong, to which it threw a SQL STATE 1046 No database selected ...
Is this desired functionality or a genuine bug?
Reproduce code:
---------------
<?php
define('DB_DSN', 'mysql:localhost;dbname=xxx');
define('DB_USER', 'xxx');
define('DB_PASS', 'xxx');
try {
$dbh = new PDO(DB_DSN, DB_USER, DB_PASS);
} catch (PDOException $e) {
die($e->getMessage());
}
// Didn't catch the exception
$dbh->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
try { $query = $dbh->query("QUERY Does not matter"); }
catch { PDOException $e) { echo $e->getMessage(); }
$dbh = null;
?>
Expected result:
----------------
An exception to be thrown, prompting an invalid DSN or something.
--
Edit bug report at http://bugs.php.net/?id=38737&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=38737&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=38737&r=trysnapshot52
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=38737&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=38737&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=38737&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=38737&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=38737&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=38737&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=38737&r=support
Expected behavior: http://bugs.php.net/fix.php?id=38737&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=38737&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=38737&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=38737&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=38737&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=38737&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=38737&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=38737&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=38737&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=38737&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=38737&r=mysqlcfg