MySQLi - Enquete
Sintaxe
int mysqli_poll (array &$read , array &$error , array &$reject , int $sec [, int $usec ])
Definição e Uso
Ele costumava pesquisar conexões.
Exemplo
Experimente o seguinte exemplo -
<?php
$servername = "localhost:3306";
$username = "root";
$password = "";
$dbname = "TUTORIALS";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error());
exit();
}
if (!mysqli_query($conn, "SET a = 1")) {
printf("Errorcode: %d\n", mysqli_error($conn));
}
echo 'Success... ' . mysqli_get_host_info($conn) . "\n";
$conn->query("SELECT 'tutorials_auto'", MYSQLI_ASYNC);
$arry_con = array($conn);
$processed = 0;
do {
$links = $errors = $reject = array();
foreach ($arry_con 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($arry_con));
$conn->close();
?>
O exemplo de saída do código acima deve ser assim -
Errorcode: 0 Success... localhost:3306 via TCP/IP Array ( [0] => tutorials_auto )