Doc #62101 [Opn->Csd]: Example coding error
Edit report at https://bugs.php.net/bug.php?id=62101&edit=1
ID: 62101
Updated by: krakjoe@php.net
Reported by: Jack dot Toering at LeadingEdgeITA dot com
Summary: Example coding error
-Status: Open
+Status: Closed
Type: Documentation Problem
Package: Documentation problem
Operating System: Windows 7
PHP Version: 5.3.13
-Assigned To:
+Assigned To: krakjoe
Block user comment: N
Private report: N
New Comment:
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.
Thank you for the report, and for helping us make our documentation better.
Previous Comments:
------------------------------------------------------------------------
[2012-05-21 23:33:19] Jack dot Toering at LeadingEdgeITA dot com
Description:
------------
---
From manual page: http://www.php.net/mysqli.poll#refsect1-mysqli.poll-examples
---
This script below is a copy and paste from the example with comments added. If reap_async_query()
fails, $processed will not be incremented, which means it will always remain less than the number of
rows in $all_links, meaning "while ($processed < count($all_links))" will remain true,
thereby creating and endless loop.
The easiest way to duplicate is to misspell one of the field names in the query string. However,
time there is a query problem, this behavior will occur.
Test script:
---------------
$link1 = mysqli_connect();
$link1->query("SELECT 'test'", MYSQLI_ASYNC);
$all_links = array($link1);
$processed = 0;
do {
$links = $errors = $reject = array();
foreach ($all_links as $link) {
$links[] = $errors[] = $reject[] = $link;
}
if (!mysqli_poll($links, $errors, $reject, 1)) {
continue;
}
foreach ($links as $link) {
if ($result = $link->reap_async_query()) { // if reap fails
print_r($result->fetch_row());
mysqli_free_result($result);
$processed++; // this not incremented
}
}
} while ($processed < count($all_links)); // this always true
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=62101&edit=1
Thread (2 messages)