ID:               38057
 Comment by:       php-bugs at ca dot jensbeimsurfen dot de
 Reported By:      draeli at draeli dot com
 Status:           No Feedback
 Bug Type:         PDO related
 Operating System: Windows
 PHP Version:      5.1.4
 New Comment:

I have a very similar problem:

<?php

        $dsn  = 'oci:dbname=//10.1.2.3/test';
        $user = 'username';
        $pass = 'password';

        $db = new PDO($dsn, $user, $pass);
        
        $st = $db->prepare("SELECT 123 FROM DUAL");

        // first try
        $st->execute();
        $ret = $st->fetch(PDO::FETCH_NUM);
        $st->closeCursor();
        var_dump($ret);
        if($ret[0] != NULL)print("ok1\n");
        if($ret[0] == 123)print("ok2\n");
        
        // second try - same code
        $st->execute();
        $ret = $st->fetch(PDO::FETCH_NUM);
        $st->closeCursor();
        var_dump($ret);
        if($ret[0] != NULL)print("ok3\n");
        if($ret[0] == 123)print("ok4\n");
                
        print("done\n");
        
?>

The output is:
-----------------------------------
array(1) {
  [0]=>
  string(3) "123"
}
ok1
ok2
array(1) {
  [0]=>
  NULL
}
done
-----------------------------------
The code works as expected if the closeCursor() call is removed.
The closeCursor documentation states that it does something equivalent
to:

do {
    while ($stmt->fetch())
        ;
    if (!$stmt->nextRowset())
        break;
} while (true);

This does not work, because nextRowset() is not implemented. 
But "while($stmt->fetch());" alone seems to work as a workaround for
closeCursor() - but it looks like that neither closeCursor nor the
workaround is necessary, as it works without them.

This was tested on PHP 5.2.6-1 with Suhosin-Patch 0.9.6.2 (cli) running
on Debian Linux.


Previous Comments:
------------------------------------------------------------------------

[2007-03-10 00:42:39] engine_no9 at gmx dot net

So far i can confirm this improper behaviour with using PDO and stored
procedure calls. I've just updated my PHP version to the latest 5.2.1
release and PDO still won't allow multiple stored procedure calls even
i've closed the cursor with the available method.

// this won't work more than once
$stmt = $db->prepare("CALL spListUsers()");

$stmt->execute();

$data = $stmt->fetchAll(PDO::FETCH_OBJ);

$stmt->closeCursor();

print_r($data);

// while this instead will work fine, even more than once
$stmt = $db->prepare("SELECT * FROM users");

$stmt->execute();

$data = $stmt->fetchAll(PDO::FETCH_OBJ);

$stmt->closeCursor();

print_r($data);

I assuming that this kind of bug is not solved in PHP 5.2.1 so far.

------------------------------------------------------------------------

[2006-07-18 01:00:01] 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-07-10 12:26:26] [EMAIL PROTECTED]

Please try using this CVS snapshot:

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



------------------------------------------------------------------------

[2006-07-10 12:24:11] draeli at draeli dot com

Description:
------------
I have this in my construct class :
$result=$this->connexion_bd->query("CALL
ListeGroupeGet($IDGroupe,'$type_sens')");
Result is correctly put with fetch method but after if I try to close
cursor with cluseCursor method nothing is do ...

To confirm this behavior, I have put an other query statement after
closeCursor method :
$test=$this->connexion_bd->query("SELECT '1'");
and do var_dump on result :
bool(false) result of that as if cursor isn"t close.

Expected result:
----------------
Fatal error: Call to a member function fetch() on a non-object 



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=38057&edit=1

Reply via email to