Bug #51596 [Com]: Exception when creating database with PDO
| From: | foo-script at o2 dot pl | Date: | Tue, 04 Jan 2011 19:39:24 +0000 |
| Subject: | Bug #51596 [Com]: Exception when creating database with PDO | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-157590@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
Comment by: foo-script at o2 dot pl
Reported by: foo-script at o2 dot pl
Summary: Exception when creating database with PDO
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:
@nw: This command ran good, I mean everything has been done.
Exception should not be thrown, cause this query has been processed and
result was fine.
You wrote: "It seems logical to me that the underlying driver code
throws an exception in case of a SQL error". The query I ran doesn't
produce any error, neither in MySQL Console, nor in JDBC.
Previous Comments:
------------------------------------------------------------------------
[2011-01-04 14:04:35] uw@php.net
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.
------------------------------------------------------------------------
[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