|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #63546 PDO::quote ignores PDO::setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION)
Submitted: 2012-11-17 11:10 UTC Modified: 2014-02-25 13:39 UTC
Avg. Score:4.2 ± 0.4
Reproduced:4 of 4 (100.0%)
Same Version:1 (25.0%)
Same OS:1 (25.0%)
From: nucer at mail dot ru Assigned:
Status: Not a bug Package: PDO related
PHP Version: 5.4.8 OS: Windows 7 x64
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: nucer at mail dot ru
New email:
PHP Version: OS:


 [2012-11-17 11:10 UTC] nucer at mail dot ru
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=", "root", "" );
$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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-03-17 09:30 UTC] spyworldxp at gmail dot com
Same case with you.

$db = new PDO("mysql:dbname=mydb;host=", "root", "" );

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
 [2014-01-21 08:52 UTC] 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 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.
 [2014-02-25 13:39 UTC]
-Status: Open +Status: Not a bug
 [2014-02-25 13:39 UTC]
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.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Jul 24 10:01:28 2024 UTC