Bug #51596 [Fbk->Wfx]: Exception when creating database with PDO
| From: | uw@php.net | Date: | Tue, 04 Jan 2011 13:04:35 +0000 |
| Subject: | Bug #51596 [Fbk->Wfx]: Exception when creating database with PDO | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-157554@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=51596&edit=1
ID: 51596
Updated by: uw@php.net
Reported by: foo-script at o2 dot pl
Summary: Exception when creating database with PDO
-Status: Feedback
+Status: Wont fix
Type: Bug
Package: PDO related
Operating System: Windows XP SP3
PHP Version: 5.3.2
Assigned To: mysql
Block user comment: N
Private report: N
New Comment:
That's a matter of the PDO API: what shall happen if init command (or
any other statement run as part of object construction/connection
establishment) generates an error? I see no bug here. It seems logical
to me that the underlying driver code throws an exception in case of a
SQL error. Be that desired or not. I'm not aware of any other way to
expose that error using todays PDO API.
Previous Comments:
------------------------------------------------------------------------
[2010-04-23 19:09:44] felipe@php.net
Please try using this snapshot:
http://snaps.php.net/php5.3-latest.tar.gz
For Windows:
http://windows.php.net/snapshots/
I can't reproduce it.
------------------------------------------------------------------------
[2010-04-19 02:40:18] foo-script at o2 dot pl
Description:
------------
A "test script" produced following exception:
exception 'PDOException' with message 'SQLSTATE[HY000]: General error'
in L:\Program Files\Apache Software
Foundation\Apache2.2\htdocs\readme.php:44 Stack trace: #0 L:\Program
Files\Apache Software Foundation\Apache2.2\htdocs\readme.php(44):
unknown() #1 {main}
However, database have been successfuly created.
Test script:
---------------
try{
$pdo=new
PDO('mysql:host='.$dbHost.';'.'dbname=mysql;'.'port='.$port,
'root', $dbKey, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES
\'UTF8\''));
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$result=$pdo->query('CREATE DATABASE test;'); }
Expected result:
----------------
In my opinion exception should not be thrown, cause effect is good.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=51596&edit=1