php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32093 mysqli_next_result does not return error code
Submitted: 2005-02-24 16:37 UTC Modified: 2005-03-25 16:28 UTC
From: michael at kofler dot cc Assigned: georg (profile)
Status: Not a bug Package: MySQLi related
PHP Version: 5CVS-2005-02-28 OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: michael at kofler dot cc
New email:
PHP Version: OS:

 

 [2005-02-24 16:37 UTC] michael at kofler dot cc
Description:
------------
PHP's mysqli_next_result uses mysql_next_result of the C API

the C function returns:

  0  (OK, there are more results)
  -1 (OK, there are no more results)
  >0 (error code for the next result)

  see http://dev.mysql.com/doc/mysql/en/mysql-next-result.html

however, the PHP function mysqli_next_result returns only TRUE (more results) or FALSE (error or no more results)

as a consequence, when processing a multi query, it is impossible to detect whether an error happend in the 2nd, 3rd etc. SQL command

Reproduce code:
---------------
  $cmd="SELECT 1;SELECT 2;SELECT bogus;SELECT 4";
  $ok = $mysqli->multi_query($cmd);
  // $ok is TRUE if the 1st SQL command was OK
  // errors in further SQL commandos do not affect $ok
  // this is to be expected, C API behave the same way

  if($ok) {
    do {
      $result = $mysqli->store_result();
      if($result) {
        ... show result ...
        $result->close();
      }
      // at this point, I would like to detect
      // whether the next result has errors or not !!!!
      $next = $mysqli->next_result();
      echo "<p>next=$next</p>\n";
    } while($next);
  }


Expected result:
----------------
I want to get this output

[result 1 ...]
next=1
[result 2 ...]
next=n > 0 so I know an error happend with the 3rd result

Actual result:
--------------
[result 1 ...]
next=1
[result 2 ...]
next=
  (this gives me no idea whether all results have
   been processed all right or whether an error has happenend)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-03-25 16:28 UTC] georg@php.net
mysqli_next_result always returns 1 if an error occured.
Use mysqli_error/errno functions to check which error occured.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 11:01:30 2024 UTC