ID: 38737 Updated by: [EMAIL PROTECTED] Reported By: mjsabby at gmail dot com -Status: Assigned +Status: Bogus Bug Type: PDO related Operating System: Fedora Core 5 PHP Version: 5.1.6 Assigned To: wez New Comment:
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php PDO allows you to connect to a database without selecting any particular database, there is nothing wrong with that. So if dbname is not parsed due to faulty DSN, and subsequently not used to select db, there is no issue with the PDO code. Previous Comments: ------------------------------------------------------------------------ [2006-09-07 01:54:04] mjsabby at gmail dot com Ok, spoke to soon about the QUERY does not matter. I guess the query matters, so instead of that, put something valid : "SELECT * FROM thisdoesnotmatter" ------------------------------------------------------------------------ [2006-09-07 01:49:34] mjsabby at gmail dot com 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 this bug report at http://bugs.php.net/?id=38737&edit=1