From: pcdinh at gmail dot com
Operating system: Windows XP
PHP version: 5.3.1
PHP Bug Type: MySQLi related
Bug description: mysqli_more_results does not play well with
mysqli_multi_query()
Description:
------------
mysqli_more_results() will always return false after
mysqli_multi_query() for both SELECT and non SELECT queries
Therefore I can not use the loop while (mysqli_more_results()) in
combination with mysqli_next_result() to iterate through result sets
produced by SELECT queries
mysqli_multi_query($conn, $query);
while (mysqli_more_results($conn))
{
mysqli_next_result($query);
/* store first result set */
if ($result = mysqli_store_result($conn)) {
}
}
Code example in http://php.net/manual/en/mysqli.multi-query.php is
outdated because it causes E_STRICT in PHP 5.3.1. It requires
mysqli_more_results() to be called before mysqli_next_result()
There is a workaround
if (mysqli_multi_query($link, $query)) {
do {
/* store first result set */
if ($result = mysqli_store_result($link)) {
while ($row = mysqli_fetch_row($result)) {
printf("%s\n", $row[0]);
}
mysqli_free_result($result);
}
// print divider => will never work
if (mysqli_more_results($link)) {
printf("-----------------\n");
}
} while (mysqli_more_results($link) && mysqli_next_result($link));
}
but mysqli_more_results() seems to do nothing related to result sets
here
Reproduce code:
---------------
<?php
$link = mysqli_connect("localhost", "root", "123456", "test");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$query = "SELECT 1";
/* execute multi query */
if (mysqli_multi_query($link, $query)) {
var_dump(mysqli_more_results($link));
}
/* close connection */
mysqli_close($link);
?>
Expected result:
----------------
bool(true)
Actual result:
--------------
bool(false)
--
Edit bug report at http://bugs.php.net/?id=50462&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=50462&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=50462&r=trysnapshot53
Try a snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=50462&r=trysnapshot60
Fixed in SVN:
http://bugs.php.net/fix.php?id=50462&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=50462&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=50462&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=50462&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=50462&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=50462&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=50462&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=50462&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=50462&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=50462&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=50462&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=50462&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=50462&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=50462&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=50462&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=50462&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=50462&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=50462&r=mysqlcfg