php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35435 PDO::query is not returning a PDOStatement object
Submitted: 2005-11-28 00:05 UTC Modified: 2005-12-05 01:00 UTC
Votes:3
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: bugs at jth dot net Assigned:
Status: No Feedback Package: Reproducible crash
PHP Version: 5.1.0 OS: Linux Fedora 3
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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: bugs at jth dot net
New email:
PHP Version: OS:

 

 [2005-11-28 00:05 UTC] bugs at jth dot net
Description:
------------
PDO::query is not returning a PDOStatement object.
and segmentation fault using array(PDO::ATTR_PERSISTENT => true)


mysqld  Ver 5.0.15-standard for pc-linux-gnu on i686 
Server version: Apache/2.0.54
Architecture:   32-bit



Reproduce code:
---------------
try {
$dbh = new PDO('mysql:host=localhost;dbname=ddddd', "xxxxx", "xxxxxxx");
$query = "SELECT COUNT(*) FROM ordrer";
$stmt = $dbh->query($query); 
//$stmt = $dbh->prepare($query);  $result = $stmt->execute();
print $stmt->columnCount();
} catch (PDOException $e) {
   print "Error  !: " . $e->getMessage() . "<br/>";
   die();
}


Actual result:
--------------
$stmt = $dbh->query($query);

Call to a member function columnCount() on a non-object
when executing code print $stmt->columnCount() but not after

$stmt = $dbh->prepare($query);  $result = $stmt->execute();

However, 
Apache2 child pid 22634 exit signal Segmentation fault (11)
in any case when using array(PDO::ATTR_PERSISTENT => true) 



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-11-28 00:18 UTC] tony2001@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip


 [2005-11-28 00:50 UTC] wez@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a backtrace to see what is happening behind the scenes. To
find out how to generate a backtrace, please read
http://bugs.php.net/bugs-generating-backtrace.php

Once you have generated a backtrace, please submit it to this bug
report and change the status back to "Open". Thank you for helping
us make PHP better.

You have no error handling code in your script.

Try also setting this before issuing queries:
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

If you're getting segfaults, we need a backtrace.

Try the latest snapshot, and please provide us with a backtrace.
 [2005-12-05 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2006-02-26 13:30 UTC] omarshariffdontlikeit at gmail dot com
I have been experiencing something similar, with the following code:

$dsn = "sqlite:foo.db";
$dbh = new PDO($dsn);
$stmt = $dbh->prepare("SELECT id, name FROM foo");

$stmt if returning a boolean value (false), thus all my folloing code fails with a "Call to a member function execute() on a non-object", which is weird as the PHP documentation states this should return a PDOStatement. In addition I tried telling PDO to change its error mode to exceptions, to see if I coult 'catch' the error, but this failed to generate an exception. Below if the code I used to set PDO to exception mode:

$dbh = new PDO($dsn);
$dbh->setAttribute(PDO::ERRMODE_EXCEPTION, true);


I know there is nothing wrong with the sqlite DB as I created it using the SQLite lib in PHP and can read it fine: I am attempting to read the same DB file using PDO.

I am running:

Win Server 2003 Ent Ed
PHP 5.1.2
Apache 2.0.55

I replaced the php_pdo.dll and php_pdo_sqlite.dll in my PHP ext directory with those in the ZIP file located at, as per your suggestion:

http://snaps.php.net/win32/php5-win32-latest.zip

I've tried to be a through as possible, and tried to add to an existing bug report (rather than generate an new report). If there is any further info you need to help diagnose this problem, drop me an email at omarshariffdontlikeit@gmail.com and I will get it for you.

Cheers!
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 05 04:01:32 2024 UTC