php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #50169 PDO::query
Submitted: 2009-11-13 18:56 UTC Modified: 2009-11-13 19:37 UTC
From: milosdj at gmail dot com Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: 5.3.0 OS: all
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: milosdj at gmail dot com
New email:
PHP Version: OS:

 

 [2009-11-13 18:56 UTC] milosdj at gmail dot com
Description:
------------
Documentation states:
Return Values
PDO::query() returns a PDOStatement object. 

Witch absolutely is not true for mysql!

if(PDO::ATTR_ERRMODE=0){PDO::query() will return FALSE;}
if(PDO::ATTR_ERRMODE=1){PDO::query() will return FALSE;} 
if(PDO::ATTR_ERRMODE=3){PDO::query() will return PDOStatement object;}

So either change PDO::query() function to always return PDOStatement object or add two sentences in PHP PDO documentation.

Reproduce code:
---------------
$db=new PDO($dsn,$user,$pass,array(PDO::ATTR_ERRMODE=>0)); // or =>1
$sql='SELECT * from tblName';

$result= $db->query($sql); // as object
if($result==false){die('Look it actually is false!!!');}

Expected result:
----------------
What documentation states. ALWAYS PDOStatement!
Please fix documentation.

Actual result:
--------------
if PDO::ERRMODE_SILENT $result is false
if PDO::ERRMODE_WARNING $result is false
if PDO::ERRMODE_EXCEPTION $result is PDOStatement

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-11-13 19:37 UTC] vrana@php.net
Already documented: "PDO::query() returns a PDOStatement object, or FALSE on failure."
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Thu Oct 08 08:00:01 2026 UTC