PHP 8.3.4 Released!

mysqli::reap_async_query

mysqli_reap_async_query

(PHP 5 >= 5.3.0, PHP 7, PHP 8)

mysqli::reap_async_query -- mysqli_reap_async_query非同期クエリから結果を取得する

説明

オブジェクト指向型

public mysqli::reap_async_query(): mysqli_result|bool

手続き型

mysqli_reap_async_query(mysqli $mysql): mysqli_result|bool

非同期クエリから結果を取得します。

注意:

mysqlnd でのみ使用可能です。

パラメータ

link

手続き型のみ: mysqli_connect() あるいは mysqli_init() が返す mysqliオブジェクト。

戻り値

失敗した場合に false を返します。 結果セットを生成するクエリ、 つまり SELECT, SHOW, DESCRIBE あるいは EXPLAIN が成功した場合は、mysqli_reap_async_query()mysqli_result オブジェクトを返します。それ以外のクエリが成功した場合は、 mysqli_reap_async_query()true を返します。

エラー / 例外

mysqli のエラー報告 (MYSQLI_REPORT_ERROR) が有効になっており、かつ要求された操作が失敗した場合は、警告が発生します。さらに、エラー報告のモードが MYSQLI_REPORT_STRICT に設定されていた場合は、mysqli_sql_exception が代わりにスローされます。

参考

add a note

User Contributed Notes 1 note

up
5
eric dot caron at gmail dot com
13 years ago
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++;
}
}
?>
To Top