php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38057 closeCursor method not function with CALL statement
Submitted: 2006-07-10 12:24 UTC Modified: 2006-07-18 01:00 UTC
Votes:6
Avg. Score:3.5 ± 1.0
Reproduced:4 of 5 (80.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: draeli at draeli dot com Assigned:
Status: No Feedback Package: PDO related
PHP Version: 5.1.4 OS: Windows
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: draeli at draeli dot com
New email:
PHP Version: OS:

 

 [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 


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-07-10 12:26 UTC] tony2001@php.net
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-18 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".
 [2007-03-10 00:42 UTC] 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.
 [2008-07-02 17:13 UTC] php-bugs at ca dot jensbeimsurfen dot de
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.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Apr 29 18:01:30 2024 UTC