FAQ
Edit report at https://pear.php.net/bugs/bug.php?id=20975&edit=1

  ID: 20975
  Comment by: trparky@toms-world.org
  Reported By: trparky at toms-world dot org
  Summary: Unable to execute another query after calling a MySQL
                     Stored Procedure
  Status: Feedback
  Type: Bug
  Package: DB
  Operating System: Linux
  Package Version: 1.8.2
  PHP Version: 5.4.45
  Roadmap Versions:
  New Comment:

Has this patch been applied to the most recent publically available
version?


Previous Comments:
------------------------------------------------------------------------

[2015-12-24 20:39:22] trparky

If I make a query against the database using a stored procedure, in my
case I use the following code...

$counterQuery = $db->query("CALL getSpecificDownloadCounter(?, ?);",
array($counterName, $fileFolder));

if ($counterQuery->numRows() != 0) {
  $result = $db->query("CALL advanceDownloadCounter(?, ?);",
array($counterName, $fileFolder));
  if (PEAR::isError($result)) die($result->getMessage());
}

The isError line will return "DB Error: no database selected". If I add
the following line of code to mysqli.php...

if (preg_match('/\ACALL.*/im', $query))
$this->connection->next_result();

Right after...
$result = @mysqli_query($this->connection, $query);
On line 400, the next query I make executes properly.

According to MySQL documentation, if you execute a stored procedure you
must execute next_result() or the next query will fail.

------------------------------------------------------------------------

[2015-11-24 14:20:30] danielc

-Status: Open
+Status: Feedback
Hi Tom:

Thank you for the patch. Please upgrade DB to version 1.9.2 without the
patch. If the problem persists, please write a short reproduce script
that makes a connection, creates a sample database and stored procedure,
executes the stored procedure then drops the database.

--Dan

------------------------------------------------------------------------

[2015-10-28 22:35:10] trparky

I have provided a patch file to fix this issue.

------------------------------------------------------------------------

[2015-10-28 22:33:02] trparky

Added #patch bug:20975;patch:mysqli.patch;revision:1446071582;.

------------------------------------------------------------------------

[2015-10-28 22:15:05] trparky

Description:
------------
After calling a MySQL Stored Procedure in MySQLi mode, you are unable to
execute another query after it. When you try to it tells you that you
have no database selected.

In order to fix this issue, you must patch mysqli.php file and add this
line...
if (preg_match('/\ACALL.*/im', $query))
$this->connection->next_result();
After this line (line 400)...
$result = @mysqli_query($this->connection, $query);

------------------------------------------------------------------------

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 1 | next ›
Discussion Overview
grouppear-bugs @
categoriesphp
postedMay 10, '16 at 8:35p
activeMay 10, '16 at 8:35p
posts1
users1
websitepear.php.net

1 user in discussion

Trparky: 1 post

People

Translate

site design / logo © 2022 Grokbase