php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39141 Only one prepared statement allowed per pdo object
Submitted: 2006-10-12 19:53 UTC Modified: 2006-10-15 18:11 UTC
From: aspen dot olmsted at alliance dot biz Assigned: wez (profile)
Status: Not a bug Package: PDO related
PHP Version: 5CVS-2006-10-12 (snap) OS: Windows XP SP2
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: aspen dot olmsted at alliance dot biz
New email:
PHP Version: OS:

 

 [2006-10-12 19:53 UTC] aspen dot olmsted at alliance dot biz
Description:
------------
If I try to open a 2nd statement handle against prepared statement on SQL 2000 and windows the 2nd attempt will fail.

I can create a new object per statement and it is fine.

The problem is only happening on prepared stored procedures.  If I prepare a sql statement it seems fine.

Reproduce code:
---------------
    $stmt = $dbh->prepare("exec pdo_test");
    $stmt->execute();
    echo $x . " " . var_dump($stmt->fetch()) . "<br>";
        // $stmt = null;
    $stmt2 = $dbh->prepare("exec pdo_test");
    $stmt2->execute();
    echo $x . " " . var_dump($stmt2->fetch()) . "<br>";

Here is the sql to create SP:
create procedure pdo_test as
select 'Hello' msg


Expected result:
----------------
Hoping both statements would print the array with Hello in it

Actual result:
--------------
The second result will print false.  If I uncomment the $stmt = null; then everything works great.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-10-15 18:11 UTC] wez@php.net
Expected behavior.  You must consume all the rows from the first statement handle before kicking off a second query.
You can do this more conveniently using fetchAll().
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 11:01:30 2024 UTC