Req #63546 [Opn->Nab]: PDO::quote ignores PDO::setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION)

From: Date: Tue, 25 Feb 2014 13:39:39 +0000
Subject: Req #63546 [Opn->Nab]: 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-184416@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
 Updated by:         uw@php.net
 Reported by:        nucer at mail dot ru
 Summary:            PDO::quote ignores
                     PDO::setAttribute(PDO::ATTR_ERRMODE,
                     PDO::ERRMODE_EXCEPTION)
-Status:             Open
+Status:             Not a bug
 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:

Warning: whatever() expects parameter 1 to be string,


This is a standard PHP function argument type mismatch warning coming from the PHP language itself,
nothing to do with PDO. PDO is a different layer. As it is filed against PDO but there is nothing
wrong with PDO behaving exactly the same way as any other PHP extension: not a bug.


Previous Comments:
------------------------------------------------------------------------
[2014-01-21 08:52:48] fk at florian-kaiser dot net

There are more PDO::method calls that issue Exceptions regardless of what PDO::ATTR_ERRMODE has been
set to. So far, I can also verify this for PDO::commit, PDO::beginTransaction, PDO::rollBack.

For some of them, the documentation actually states that they might emit a PDOException, for others
there is no information on error handling. If you can set PDO::ATTR_ERRMODE you can expect that
after issuing the attribute, all functions respect the mode and behave accordingly and will only
behave otherwise if documented clearly.

If this is intended behaviour, please update the documentation on php.net to reflect that. If it is
not, please fix the underlying implementation and look for other methods that might not honor the
ATTR_ERRMODE setting.

Btw, same behaviour on Linux, and also with 5.5.8.

------------------------------------------------------------------------
[2013-03-17 09:30:04] spyworldxp at gmail dot com

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

------------------------------------------------------------------------
[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


Thread (4 messages)

« previous php.bugs (#184416) next »