php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43707 PDOStatement->nextRowset() doesn't work
Submitted: 2007-12-29 20:44 UTC Modified: 2008-07-23 11:36 UTC
Votes:3
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: lunter at interia dot pl Assigned:
Status: Closed Package: PDO related
PHP Version: 5.3CVS-2007-12-29 (CVS) OS: WinXP
Private report: No CVE-ID: None
 [2007-12-29 20:44 UTC] lunter at interia dot pl
Description:
------------
PDOStatement->nextRowset() doesn't work


Reproduce code:
---------------
<?
 $h=new PDO('mysql:host=localhost;dbname=root','root','root');

// $q=$h->query('CALL some_proc()');
 $q=$h->query('SELECT 1 AS col;SELECT 2 AS col;');

 $r=$q->fetchAll(PDO::FETCH_ASSOC);
 print_r($r);

 $q->nextRowset();
 $r=$q->fetchAll(PDO::FETCH_ASSOC);
 print_r($r);
?>


Expected result:
----------------
Array ( [0] => Array ( [col] => 1 ) ) 

Array ( [0] => Array ( [col] => 2 ) ) 


Actual result:
--------------
Array ( [0] => Array ( [col] => 1 ) ) 

Array ( ) 


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-12-30 12:36 UTC] lunter at interia dot pl
This is rather important bug, becouse it doesn't permite to full use stored procedured by MySQL, MS SQL etc. programmers.
 [2008-01-23 23:28 UTC] dev at bcdiv dot com
Experiencing similar issue.

Environment: 
Vista Ultimate
Apache/2.0.61 (Win32) PHP/5.2.5
MySQL Client API version  5.0.45
PDO Driver for MySQL, client library version 5.0.45

MySQL:
stored proc executes properly in MySQL QueryBrowser giving proper result of 2 recordsets (recordsets contain only small varchar fields, ints, booleans so should not be an issue related to size of the returning records or #s of them)

PHP:
successfully use PDO with stored procs producing 1 recordset, but
using the above stored proc only the first recordset can be retrieved
attempting to test for nextRecordset results in optional feature not implemented error.

CODE:
(Am just including the bare minimum to see if I can move from the first recordset to the next)

		$cn = new PDO;
		$cn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

		$sp = $cn->prepare("CALL spGetInfo(?,?)");
		$sp->bindParam(1,$oID, PDO::PARAM_INT);
		$sp->bindParam(2,$cID, PDO::PARAM_INT);

                $result = $sp->execute();
		echo "result = ".$result."<br />";
		$err = $oConn->errorCode();
		$errmsg = $oConn->errorInfo();
		if($err > 0){
		  print_r("sproc returned error: " .$err." ErrorMsg: ".$errmsg." value<br />");
		}else{
          for($i=0; $oRow = $sp->fetch(PDO::FETCH_ASSOC); $i++){
                 echo var_dump($oRow);
          }
                }

RESULT:
result = 1
array(3) { ["oID"]=> string(5) "28353" ["cID"]=> string(1) "0" ["sv"]=> NULL } 

Error!: SQLSTATE[HYC00]: Optional feature not implemented


SIMILAR BUGS:
Review of other bugs shows a number open, but some comments indicate that perhaps this is an issue resolved if I use another version of the DLL libraries for pdo_mysql or pdo? 
Even using the latest snap of these (copying over the dlls only into the PHP ext folder, then restarting Apache)doesn't seem to resolve the problem.
#34727 One bug said these had to be compiled, but that was in 2005, and it seems perhaps an out-dated comment.
#43709 seems to indicate this issue isn't going to be fixed except by revising the documentation for the current version.

QUESTIONS:
Though I note bugs shouldn't raise questions, online documenation may benefit by answering these -- specifically in the manual. Surely it would reduce the number of pings to you on the subject. PDO on the whole has worked very well for the single recordset sprocs, so hopefully its simply a matter of configuration.
(1) What version of PHP enables nextRowset() for WIN32/MySQL?
(2) If no available version enables this feature, what version should it be anticipated?
(3) Are there work-arounds are being used with PDO for the return of multiple recordsets?

Thanks! This is definitely an important issue for any of us using stored procs that return multiple recordsets.
 [2008-01-24 21:30 UTC] dev at bcdiv dot com
Correction to the above note (23 Jan 11:28pm UTC):

All references of "oConn" should read "cn" instead.
 [2008-05-14 08:24 UTC] darren at viamedia dot co dot za
I have it working fine in PHP 5.1.6
Any idea if this is still an issue in 5.2.6?
 [2008-07-23 11:36 UTC] johannes@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

Best is to build PHP using mysqlnd --with-pdo-mysql=mysqlnd
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 12:01:30 2024 UTC