Bug->Doc #44305 [Ver]: odbc_next_result - mysql procedure with multiple results
| From: | cmb@php.net | Date: | Fri, 26 Mar 2021 15:33:27 +0000 |
| Subject: | Bug->Doc #44305 [Ver]: odbc_next_result - mysql procedure with multiple results | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-18671@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=44305&edit=1
ID: 44305
Updated by: cmb@php.net
Reported by: martin dot dufka at atlas dot cz
Summary: odbc_next_result - mysql procedure with multiple
results
Status: Verified
-Type: Bug
+Type: Documentation Problem
Package: ODBC related
Operating System: WIN2000
PHP Version: 7.3
Block user comment: N
Private report: N
New Comment:
This is indeed expected behavior with MySQL[1] (and maybe other
drivers):
| This is because each CALL returns a result to indicate the call
| status, in addition to any result sets that might be returned by
| statements executed within the procedure.
I think we should document that the warning can be prevented by
checking for
odbc_num_fields($result) > 0 before fetching.
[1] <https://dev.mysql.com/doc/refman/8.0/en/call.html>
Previous Comments:
------------------------------------------------------------------------
[2020-10-02 21:36:09] cmb@php.net
I can confirm the reported behavior for PHP-7.3 with the MySQL
ODBC 8.0 Unicode driver, while the ODBC driver 17 for SQL Server
behaves as expected. PDO_ODBC shows basically the same behavior.
It seems to me that adding the additional result set is a quirk
of MySQL, but I don't see how that result set would be useful in
any way, since SQLNumResultCols() as well as SQLRowCount() yield
zero for it.
------------------------------------------------------------------------
[2008-03-01 17:04:15] martin dot dufka at atlas dot cz
Description:
------------
problem with: odbc_next_result()
mysql-server: 5.0.51a (.45-the same problem)
odbc driver: Driver={MySQL ODBC 3.51 Driver}
when MySQL procedure returns 2 rowsets, after the second rowset odbc_next_result() returns true.
Reproduce code:
---------------
<?php
/*
mysql:
CREATE PROCEDURE multiplerowsets()
BEGIN
select 'rs1';
select 'rs2';
END;
*/
$dsn="Driver={MySQL ODBC 3.51 Driver};Server=localhost;Port=3306;Database=db_name;";
$conn=odbc_connect($dsn,'user','passwd');
$query="call multiplerowsets";
$result=odbc_exec($conn,$query);
$row=odbc_fetch_array ($result); var_dump(odbc_next_result($result));
$row=odbc_fetch_array ($result); var_dump(odbc_next_result($result));
$row=odbc_fetch_array ($result); var_dump(odbc_next_result($result));
?>
Expected result:
----------------
bool(true) bool(false) bool(false)
Actual result:
--------------
bool(true) bool(true)
Warning: odbc_fetch_array() [function.odbc-fetch-array]: No tuples available at this result index in
D:\Apache2.2\htdocs\test\x.php on line 19
bool(false)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=44305&edit=1