|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-07-10 12:24 UTC] 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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 08:00:01 2025 UTC |
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.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.