Req #63546 [Com]: PDO::quote ignores PDO::setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION)
| From: | spyworldxp at gmail dot com | Date: | Sun, 17 Mar 2013 09:30:04 +0000 |
| Subject: | Req #63546 [Com]: PDO::quote ignores PDO::setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION) | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-177844@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=63546&edit=1
ID: 63546
Comment by: spyworldxp at gmail dot com
Reported by: nucer at mail dot ru
Summary: PDO::quote ignores
PDO::setAttribute(PDO::ATTR_ERRMODE,
PDO::ERRMODE_EXCEPTION)
Status: Open
Type: Feature/Change Request
Package: PDO related
Operating System: Windows 7 x64
PHP Version: 5.4.8
Block user comment: N
Private report: N
New Comment:
Same case with you.
Script
-----------------
$db = new PDO("mysql:dbname=mydb;host=127.0.0.1", "root", "" );
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);
Error Message
-----------------
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [1049]
Unknown database 'mydb'' in D:\var\www\class\mysql.php:33 Stack
trace: #0 D:\var\www\class\mysql.php(33): PDO->__construct('mysql:host=127....',
'root', 'root') #1 D:\var\www\class\mysql.php(20): mysql->connect()
#2 D:\var\www\test.php(5): mysql->__construct() #3 {main} thrown in D:\var\www\class\mysql.php on
line 33
Previous Comments:
------------------------------------------------------------------------
[2012-11-17 11:10:38] nucer at mail dot ru
Description:
------------
It looks like PDO::quote ignores PDO::setAttribute(PDO::ATTR_ERRMODE,
PDO::ERRMODE_EXCEPTION); always sending warning, not exception.
Test script:
---------------
$db = new PDO("mysql:dbname=mydb;host=127.0.0.1", "root", "" );
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db->quote( array() );
Actual result:
--------------
Warning: PDO::quote() expects parameter 1 to be string, array given in
Z:\home\test\www\test\db.php on line 27
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=63546&edit=1