mysqli::poll
mysqli_poll
(PHP 5 >= 5.3.0, PHP 7)
mysqli::poll -- mysqli_poll — Poll connections
Description
Object oriented style
&$read
, array &$error
, array &$reject
, int $sec
[, int $usec
= 0
] ) : intProcedural style
&$read
, array &$error
, array &$reject
, int $sec
[, int $usec
= 0
] ) : intPoll connections. Available only with mysqlnd. The method can be used as static.
Parameters
-
read
-
List of connections to check for outstanding results that can be read.
-
error
-
List of connections on which an error occured, for example, query failure or lost connection.
-
reject
-
List of connections rejected because no asynchronous query has been run on for which the function could poll results.
-
sec
-
Maximum number of seconds to wait, must be non-negative.
-
usec
-
Maximum number of microseconds to wait, must be non-negative.
Examples
Example #1 A mysqli_poll() example
<?php
$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()) {
print_r($result->fetch_row());
if (is_object($result))
mysqli_free_result($result);
} else die(sprintf("MySQLi Error: %s", mysqli_error($link)));
$processed++;
}
} while ($processed < count($all_links));
?>
The above example will output:
Array ( [0] => test )
See Also
- mysqli_query() - Performs a query on the database
- mysqli_reap_async_query() - Get result from async query
English translation
You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.
Thank you in advance.
Document created the 30/01/2003, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/php-rf-mysqli.poll.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.
References
These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.