Ask a Question related to PHP Bugs, Design and Development.
-
vunnuk_o at ukr dot net #1
#40772 [NEW]: PDO::query() does not raise exception
From: vunnuk_o at ukr dot net
Operating system: Win XP
PHP version: 5.2.1
PHP Bug Type: PDO related
Bug description: PDO::query() does not raise exception
Description:
------------
PDO::query() does not throw an error when the SQL query contains syntax
error
Reproduce code:
---------------
$pdo = new PDO($dsn, $user, $pass,
array(PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION));
$pdo->query("SELETC * FROM test");
Expected result:
----------------
Exception should be raised.
Actual result:
--------------
Exception is not raised
but $pdo->errorCode() reports 42000
--
Edit bug report at [url]http://bugs.php.net/?id=40772&edit=1[/url]
--
Try a CVS snapshot (PHP 4.4): [url]http://bugs.php.net/fix.php?id=40772&r=trysnapshot44[/url]
Try a CVS snapshot (PHP 5.2): [url]http://bugs.php.net/fix.php?id=40772&r=trysnapshot52[/url]
Try a CVS snapshot (PHP 6.0): [url]http://bugs.php.net/fix.php?id=40772&r=trysnapshot60[/url]
Fixed in CVS: [url]http://bugs.php.net/fix.php?id=40772&r=fixedcvs[/url]
Fixed in release: [url]http://bugs.php.net/fix.php?id=40772&r=alreadyfixed[/url]
Need backtrace: [url]http://bugs.php.net/fix.php?id=40772&r=needtrace[/url]
Need Reproduce Script: [url]http://bugs.php.net/fix.php?id=40772&r=needscript[/url]
Try newer version: [url]http://bugs.php.net/fix.php?id=40772&r=oldversion[/url]
Not developer issue: [url]http://bugs.php.net/fix.php?id=40772&r=support[/url]
Expected behavior: [url]http://bugs.php.net/fix.php?id=40772&r=notwrong[/url]
Not enough info: [url]http://bugs.php.net/fix.php?id=40772&r=notenoughinfo[/url]
Submitted twice: [url]http://bugs.php.net/fix.php?id=40772&r=submittedtwice[/url]
register_globals: [url]http://bugs.php.net/fix.php?id=40772&r=globals[/url]
PHP 3 support discontinued: [url]http://bugs.php.net/fix.php?id=40772&r=php3[/url]
Daylight Savings: [url]http://bugs.php.net/fix.php?id=40772&r=dst[/url]
IIS Stability: [url]http://bugs.php.net/fix.php?id=40772&r=isapi[/url]
Install GNU Sed: [url]http://bugs.php.net/fix.php?id=40772&r=gnused[/url]
Floating point limitations: [url]http://bugs.php.net/fix.php?id=40772&r=float[/url]
No Zend Extensions: [url]http://bugs.php.net/fix.php?id=40772&r=nozend[/url]
MySQL Configuration Error: [url]http://bugs.php.net/fix.php?id=40772&r=mysqlcfg[/url]
vunnuk_o at ukr dot net Guest
-
#36681 [Ver->Csd]: pgsql: Deferred constraints do not raise an exception on commit
ID: 36681 Updated by: iliaa@php.net Reported By: ce at netage dot bg -Status: Verified +Status: ... -
#38737 [Opn->Bgs]: Invalid DSN doesn't raise exception, connects to server, doesn't select DB
ID: 38737 Updated by: iliaa@php.net Reported By: mjsabby at gmail dot com -Status: Open +Status: ... -
#38737 [Bgs->Opn]: Invalid DSN doesn't raise exception, connects to server, doesn't select DB
ID: 38737 User updated by: mjsabby at gmail dot com Reported By: mjsabby at gmail dot com -Status: Bogus +Status: ... -
#38737 [Asn->Bgs]: Invalid DSN doesn't raise exception, connects to server, doesn't select DB
ID: 38737 Updated by: iliaa@php.net Reported By: mjsabby at gmail dot com -Status: Assigned +Status: ... -
how to throw (raise) exception from a custom control
Here is an interesting situation I'm facing while creating custom controls. Problem Abstract: Unable to throw a exception from within the custom... -
iliaa@php.net #2
#40772 [Opn->Fbk]: PDO::query() does not raise exception
ID: 40772
Updated by: [email]iliaa@php.net[/email]
Reported By: vunnuk_o at ukr dot net
-Status: Open
+Status: Feedback
Bug Type: PDO related
Operating System: Win XP
PHP Version: 5.2.1
New Comment:
What PDO back-end are you using?
Previous Comments:
------------------------------------------------------------------------
[2007-03-10 18:49:24] vunnuk_o at ukr dot net
Description:
------------
PDO::query() does not throw an error when the SQL query contains syntax
error
Reproduce code:
---------------
$pdo = new PDO($dsn, $user, $pass,
array(PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION));
$pdo->query("SELETC * FROM test");
Expected result:
----------------
Exception should be raised.
Actual result:
--------------
Exception is not raised
but $pdo->errorCode() reports 42000
------------------------------------------------------------------------
--
Edit this bug report at [url]http://bugs.php.net/?id=40772&edit=1[/url]
iliaa@php.net Guest
-
vunnuk_o at ukr dot net #3
#40772 [Fbk->Opn]: PDO::query() does not raise exception
ID: 40772
User updated by: vunnuk_o at ukr dot net
Reported By: vunnuk_o at ukr dot net
-Status: Feedback
+Status: Open
Bug Type: PDO related
Operating System: Win XP
PHP Version: 5.2.1
New Comment:
This happens for MySQL an SQLite
Previous Comments:
------------------------------------------------------------------------
[2007-03-11 14:42:16] [email]iliaa@php.net[/email]
What PDO back-end are you using?
------------------------------------------------------------------------
[2007-03-10 18:49:24] vunnuk_o at ukr dot net
Description:
------------
PDO::query() does not throw an error when the SQL query contains syntax
error
Reproduce code:
---------------
$pdo = new PDO($dsn, $user, $pass,
array(PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION));
$pdo->query("SELETC * FROM test");
Expected result:
----------------
Exception should be raised.
Actual result:
--------------
Exception is not raised
but $pdo->errorCode() reports 42000
------------------------------------------------------------------------
--
Edit this bug report at [url]http://bugs.php.net/?id=40772&edit=1[/url]
vunnuk_o at ukr dot net Guest
-
vunnuk_o at ukr dot net #4
#40772 [Opn]: PDO::query() does not raise exception
ID: 40772
User updated by: vunnuk_o at ukr dot net
Reported By: vunnuk_o at ukr dot net
Status: Open
Bug Type: PDO related
Operating System: Win XP
PHP Version: 5.2.1
New Comment:
However, SQLite's errorCode() is HY000... should not be 42000?
Previous Comments:
------------------------------------------------------------------------
[2007-03-11 15:47:27] vunnuk_o at ukr dot net
This happens for MySQL an SQLite
------------------------------------------------------------------------
[2007-03-11 14:42:16] [email]iliaa@php.net[/email]
What PDO back-end are you using?
------------------------------------------------------------------------
[2007-03-10 18:49:24] vunnuk_o at ukr dot net
Description:
------------
PDO::query() does not throw an error when the SQL query contains syntax
error
Reproduce code:
---------------
$pdo = new PDO($dsn, $user, $pass,
array(PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION));
$pdo->query("SELETC * FROM test");
Expected result:
----------------
Exception should be raised.
Actual result:
--------------
Exception is not raised
but $pdo->errorCode() reports 42000
------------------------------------------------------------------------
--
Edit this bug report at [url]http://bugs.php.net/?id=40772&edit=1[/url]
vunnuk_o at ukr dot net Guest
-
dennis at inmarket dot lviv dot ua #5
#40772 [Com]: PDO::query() does not raise exception
ID: 40772
Comment by: dennis at inmarket dot lviv dot ua
Reported By: vunnuk_o at ukr dot net
Status: Open
Bug Type: PDO related
Operating System: Win XP
PHP Version: 5.2.1
New Comment:
Looks like PDO constructor does not like the PDO::ATTR_ERRMODE in the
options array. This way works:
$conn = new PDO($dsn, $user, $pass);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$conn->query("SELETC * FROM test"); // throws a PDOException
However, for SQLite the SQLSTATE still is HY000 instead of 42000
Previous Comments:
------------------------------------------------------------------------
[2007-03-11 15:53:21] vunnuk_o at ukr dot net
However, SQLite's errorCode() is HY000... should not be 42000?
------------------------------------------------------------------------
[2007-03-11 15:47:27] vunnuk_o at ukr dot net
This happens for MySQL an SQLite
------------------------------------------------------------------------
[2007-03-11 14:42:16] [email]iliaa@php.net[/email]
What PDO back-end are you using?
------------------------------------------------------------------------
[2007-03-10 18:49:24] vunnuk_o at ukr dot net
Description:
------------
PDO::query() does not throw an error when the SQL query contains syntax
error
Reproduce code:
---------------
$pdo = new PDO($dsn, $user, $pass,
array(PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION));
$pdo->query("SELETC * FROM test");
Expected result:
----------------
Exception should be raised.
Actual result:
--------------
Exception is not raised
but $pdo->errorCode() reports 42000
------------------------------------------------------------------------
--
Edit this bug report at [url]http://bugs.php.net/?id=40772&edit=1[/url]
dennis at inmarket dot lviv dot ua Guest
-
iliaa@php.net #6
#40772 [Opn->Bgs]: PDO::query() does not raise exception
ID: 40772
Updated by: [email]iliaa@php.net[/email]
Reported By: vunnuk_o at ukr dot net
-Status: Open
+Status: Bogus
Bug Type: PDO related
Operating System: Win XP
PHP Version: 5.2.1
New Comment:
Unfortunately on syntax errors SQLite returns a generic "error"
message,
which is why PHP returns HY000 error code.
As far as constructor not support exception option setting, I cannot
seem to replicate in SQLite. Here is the sample code I am using
$d = new PDO('sqlite:test.db', NULL, NULL, array(PDO::ATTR_ERRMODE,
PDO::ERRMODE_EXCEPTION));
$d->query("SELETC * FROM test");
Previous Comments:
------------------------------------------------------------------------
[2007-03-11 17:24:35] dennis at inmarket dot lviv dot ua
Looks like PDO constructor does not like the PDO::ATTR_ERRMODE in the
options array. This way works:
$conn = new PDO($dsn, $user, $pass);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$conn->query("SELETC * FROM test"); // throws a PDOException
However, for SQLite the SQLSTATE still is HY000 instead of 42000
------------------------------------------------------------------------
[2007-03-11 15:53:21] vunnuk_o at ukr dot net
However, SQLite's errorCode() is HY000... should not be 42000?
------------------------------------------------------------------------
[2007-03-11 15:47:27] vunnuk_o at ukr dot net
This happens for MySQL an SQLite
------------------------------------------------------------------------
[2007-03-11 14:42:16] [email]iliaa@php.net[/email]
What PDO back-end are you using?
------------------------------------------------------------------------
[2007-03-10 18:49:24] vunnuk_o at ukr dot net
Description:
------------
PDO::query() does not throw an error when the SQL query contains syntax
error
Reproduce code:
---------------
$pdo = new PDO($dsn, $user, $pass,
array(PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION));
$pdo->query("SELETC * FROM test");
Expected result:
----------------
Exception should be raised.
Actual result:
--------------
Exception is not raised
but $pdo->errorCode() reports 42000
------------------------------------------------------------------------
--
Edit this bug report at [url]http://bugs.php.net/?id=40772&edit=1[/url]
iliaa@php.net Guest
-
vunnuk_o at ukr dot net #7
#40772 [Bgs->Opn]: PDO::query() does not raise exception
ID: 40772
User updated by: vunnuk_o at ukr dot net
Reported By: vunnuk_o at ukr dot net
-Status: Bogus
+Status: Open
Bug Type: PDO related
Operating System: Win XP
PHP Version: 5.2.1
New Comment:
This works on Linux (SQLite) but fails on Windows. So still a bug.
Also, your example has an error
array(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION));
should be
array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
Otherwise on Linux it leads to another error:
The auto-commit mode cannot be changed for this driver
Previous Comments:
------------------------------------------------------------------------
[2007-03-11 18:31:22] [email]iliaa@php.net[/email]
Unfortunately on syntax errors SQLite returns a generic "error"
message,
which is why PHP returns HY000 error code.
As far as constructor not support exception option setting, I cannot
seem to replicate in SQLite. Here is the sample code I am using
$d = new PDO('sqlite:test.db', NULL, NULL, array(PDO::ATTR_ERRMODE,
PDO::ERRMODE_EXCEPTION));
$d->query("SELETC * FROM test");
------------------------------------------------------------------------
[2007-03-11 17:24:35] dennis at inmarket dot lviv dot ua
Looks like PDO constructor does not like the PDO::ATTR_ERRMODE in the
options array. This way works:
$conn = new PDO($dsn, $user, $pass);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$conn->query("SELETC * FROM test"); // throws a PDOException
However, for SQLite the SQLSTATE still is HY000 instead of 42000
------------------------------------------------------------------------
[2007-03-11 15:53:21] vunnuk_o at ukr dot net
However, SQLite's errorCode() is HY000... should not be 42000?
------------------------------------------------------------------------
[2007-03-11 15:47:27] vunnuk_o at ukr dot net
This happens for MySQL an SQLite
------------------------------------------------------------------------
[2007-03-11 14:42:16] [email]iliaa@php.net[/email]
What PDO back-end are you using?
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
[url]http://bugs.php.net/40772[/url]
--
Edit this bug report at [url]http://bugs.php.net/?id=40772&edit=1[/url]
vunnuk_o at ukr dot net Guest
-
tony2001@php.net #8
#40772 [Opn->Fbk]: PDO::query() does not raise exception
ID: 40772
Updated by: [email]tony2001@php.net[/email]
Reported By: vunnuk_o at ukr dot net
-Status: Open
+Status: Feedback
Bug Type: PDO related
Operating System: Win XP
PHP Version: 5.2.1
New Comment:
Which PHP version are you using?>This works on Linux (SQLite) but fails on Windows.
How is that related to your problem and how to reproduce it?>Otherwise on Linux it leads to another error:
>The auto-commit mode cannot be changed for this driver
Previous Comments:
------------------------------------------------------------------------
[2007-03-11 20:02:56] vunnuk_o at ukr dot net
This works on Linux (SQLite) but fails on Windows. So still a bug.
Also, your example has an error
array(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION));
should be
array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
Otherwise on Linux it leads to another error:
The auto-commit mode cannot be changed for this driver
------------------------------------------------------------------------
[2007-03-11 18:31:22] [email]iliaa@php.net[/email]
Unfortunately on syntax errors SQLite returns a generic "error"
message,
which is why PHP returns HY000 error code.
As far as constructor not support exception option setting, I cannot
seem to replicate in SQLite. Here is the sample code I am using
$d = new PDO('sqlite:test.db', NULL, NULL, array(PDO::ATTR_ERRMODE,
PDO::ERRMODE_EXCEPTION));
$d->query("SELETC * FROM test");
------------------------------------------------------------------------
[2007-03-11 17:24:35] dennis at inmarket dot lviv dot ua
Looks like PDO constructor does not like the PDO::ATTR_ERRMODE in the
options array. This way works:
$conn = new PDO($dsn, $user, $pass);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$conn->query("SELETC * FROM test"); // throws a PDOException
However, for SQLite the SQLSTATE still is HY000 instead of 42000
------------------------------------------------------------------------
[2007-03-11 15:53:21] vunnuk_o at ukr dot net
However, SQLite's errorCode() is HY000... should not be 42000?
------------------------------------------------------------------------
[2007-03-11 15:47:27] vunnuk_o at ukr dot net
This happens for MySQL an SQLite
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
[url]http://bugs.php.net/40772[/url]
--
Edit this bug report at [url]http://bugs.php.net/?id=40772&edit=1[/url]
tony2001@php.net Guest
-
vunnuk_o at ukr dot net #9
#40772 [Fbk->Opn]: PDO::query() does not raise exception
ID: 40772
User updated by: vunnuk_o at ukr dot net
Reported By: vunnuk_o at ukr dot net
-Status: Feedback
+Status: Open
Bug Type: PDO related
Operating System: Win XP
PHP Version: 5.2.1
New Comment:
5.2.1>Which PHP version are you using?>>This works on Linux (SQLite) but fails on Windows.
It's not related; just telling that Ilia's code has an error:>How is that related to your problem and how to reproduce it?>>Otherwise on Linux it leads to another error:
>>The auto-commit mode cannot be changed for this driver
$d = new PDO('sqlite:test.db', NULL, NULL, array(PDO::ATTR_ERRMODE,
PDO::ERRMODE_EXCEPTION));
should be
$d = new PDO('sqlite:test.db', NULL, NULL, array(PDO::ATTR_ERRMODE =>
PDO::ERRMODE_EXCEPTION));
Previous Comments:
------------------------------------------------------------------------
[2007-03-12 09:22:42] [email]tony2001@php.net[/email]
Which PHP version are you using?>This works on Linux (SQLite) but fails on Windows.
How is that related to your problem and how to reproduce it?>Otherwise on Linux it leads to another error:
>The auto-commit mode cannot be changed for this driver
------------------------------------------------------------------------
[2007-03-11 20:02:56] vunnuk_o at ukr dot net
This works on Linux (SQLite) but fails on Windows. So still a bug.
Also, your example has an error
array(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION));
should be
array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
Otherwise on Linux it leads to another error:
The auto-commit mode cannot be changed for this driver
------------------------------------------------------------------------
[2007-03-11 18:31:22] [email]iliaa@php.net[/email]
Unfortunately on syntax errors SQLite returns a generic "error"
message,
which is why PHP returns HY000 error code.
As far as constructor not support exception option setting, I cannot
seem to replicate in SQLite. Here is the sample code I am using
$d = new PDO('sqlite:test.db', NULL, NULL, array(PDO::ATTR_ERRMODE,
PDO::ERRMODE_EXCEPTION));
$d->query("SELETC * FROM test");
------------------------------------------------------------------------
[2007-03-11 17:24:35] dennis at inmarket dot lviv dot ua
Looks like PDO constructor does not like the PDO::ATTR_ERRMODE in the
options array. This way works:
$conn = new PDO($dsn, $user, $pass);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$conn->query("SELETC * FROM test"); // throws a PDOException
However, for SQLite the SQLSTATE still is HY000 instead of 42000
------------------------------------------------------------------------
[2007-03-11 15:53:21] vunnuk_o at ukr dot net
However, SQLite's errorCode() is HY000... should not be 42000?
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
[url]http://bugs.php.net/40772[/url]
--
Edit this bug report at [url]http://bugs.php.net/?id=40772&edit=1[/url]
vunnuk_o at ukr dot net Guest
-
tony2001@php.net #10
#40772 [Opn->Fbk]: PDO::query() does not raise exception
ID: 40772
Updated by: [email]tony2001@php.net[/email]
Reported By: vunnuk_o at ukr dot net
-Status: Open
+Status: Feedback
Bug Type: PDO related
Operating System: Win XP
PHP Version: 5.2.1
New Comment:
Please try using this CVS snapshot:
[url]http://snaps.php.net/php5.2-latest.tar.gz[/url]
For Windows:
[url]http://snaps.php.net/win32/php5.2-win32-latest.zip[/url]
Previous Comments:
------------------------------------------------------------------------
[2007-03-12 10:59:24] vunnuk_o at ukr dot net
5.2.1>Which PHP version are you using?>>This works on Linux (SQLite) but fails on Windows.
It's not related; just telling that Ilia's code has an error:>How is that related to your problem and how to reproduce it?>>Otherwise on Linux it leads to another error:
>>The auto-commit mode cannot be changed for this driver
$d = new PDO('sqlite:test.db', NULL, NULL, array(PDO::ATTR_ERRMODE,
PDO::ERRMODE_EXCEPTION));
should be
$d = new PDO('sqlite:test.db', NULL, NULL, array(PDO::ATTR_ERRMODE =>
PDO::ERRMODE_EXCEPTION));
------------------------------------------------------------------------
[2007-03-12 09:22:42] [email]tony2001@php.net[/email]
Which PHP version are you using?>This works on Linux (SQLite) but fails on Windows.
How is that related to your problem and how to reproduce it?>Otherwise on Linux it leads to another error:
>The auto-commit mode cannot be changed for this driver
------------------------------------------------------------------------
[2007-03-11 20:02:56] vunnuk_o at ukr dot net
This works on Linux (SQLite) but fails on Windows. So still a bug.
Also, your example has an error
array(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION));
should be
array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
Otherwise on Linux it leads to another error:
The auto-commit mode cannot be changed for this driver
------------------------------------------------------------------------
[2007-03-11 18:31:22] [email]iliaa@php.net[/email]
Unfortunately on syntax errors SQLite returns a generic "error"
message,
which is why PHP returns HY000 error code.
As far as constructor not support exception option setting, I cannot
seem to replicate in SQLite. Here is the sample code I am using
$d = new PDO('sqlite:test.db', NULL, NULL, array(PDO::ATTR_ERRMODE,
PDO::ERRMODE_EXCEPTION));
$d->query("SELETC * FROM test");
------------------------------------------------------------------------
[2007-03-11 17:24:35] dennis at inmarket dot lviv dot ua
Looks like PDO constructor does not like the PDO::ATTR_ERRMODE in the
options array. This way works:
$conn = new PDO($dsn, $user, $pass);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$conn->query("SELETC * FROM test"); // throws a PDOException
However, for SQLite the SQLSTATE still is HY000 instead of 42000
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
[url]http://bugs.php.net/40772[/url]
--
Edit this bug report at [url]http://bugs.php.net/?id=40772&edit=1[/url]
tony2001@php.net Guest



Reply With Quote

