Keep in mind that mysqli::reap_async_query only returns mysqli_result on queries like SELECT. For queries where you may be interested in things like affected_rows or insert_id, you can't work off of the result of mysqli::reap_async_query as the example in mysqli::poll leads you to believe. For INSERT/UPDATE/DELETE queries, the data corresponding to the query can be accessed through the associated key to the first array in the mysqli::poll function.
So instead of
<?php
foreach ($links as $link) {
if ($result = $link->reap_async_query()) {
print_r($result->fetch_row());
mysqli_free_result($result);
$processed++;
}
}
?>
The data is accessible via:
<?php
foreach ($links as $link) {
if ($result = $link->reap_async_query()) {
//This works for SELECT
if(is_object($result)){
print_r($result->fetch_row());
mysqli_free_result($result);
}
//This works for INSERT/UPDATE/DELETE
else {
print_r($link);
}
$processed++;
}
}
?>
mysqli::reap_async_query
mysqli_reap_async_query
(PHP 5 >= 5.3.0)
mysqli::reap_async_query -- mysqli_reap_async_query — 非同期クエリから結果を取得する
説明
オブジェクト指向型
手続き型
警告
この関数は、 現在のところ詳細な情報はありません。引数のリストのみが 記述されています。
非同期クエリから結果を取得します。 mysqlnd でのみ使用可能です。
返り値
成功した場合に mysqli_result、それ以外の場合に FALSE を返します。
eric dot caron at gmail dot com
06-May-2010 11:05
