- MySQLi 教程
- MySQLi - 首頁
- MySQLi - 介紹
- MySQLi - PHP 語法
- MySQLi - 連線
- MySQLi - 建立資料庫
- MySQLi - 刪除資料庫
- MySQLi - 選擇資料庫
- MySQLi - 建立表
- MySQLi - 刪除表
- MySQLi - 插入查詢
- MySQLi - 選擇查詢
- MySQLi - Where 子句
- MySQLi - 更新查詢
- MySQLi - 刪除查詢
- MySQLi - Like 子句
- MySQLi - 排序結果
- MySQLi - 使用連線
- MySQLi - 處理 NULL 值
- 獲取和使用 MySQLi 元資料
- MySQL
- MySQL - 安裝
- MySQL - 管理
- MySQL - 資料型別
- MySQL - 正則表示式
- MySQL - 事務
- MySQL - Alter 命令
- MySQL - 索引
- MySQL - 臨時表
- MySQL - 克隆表
- MySQL - 使用序列
- MySQL - 處理重複
- MySQLi 有用資源
- MySQLi - 有用函式
- MySQLi - 快速指南
- MySQLi - 有用資源
- MySQLi - 討論
MySQLi - 輪詢
語法
int mysqli_poll (array &$read , array &$error , array &$reject , int $sec [, int $usec ])
定義和用法
它用於輪詢連線。
示例
嘗試以下示例 -
<?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();
?>
以上程式碼的示例輸出應如下 -
Errorcode: 0 Success... localhost:3306 via TCP/IP Array ( [0] => tutorials_auto )
mysqli_useful_functions.htm
廣告