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_queryRuft das Ergebnis einer asynchronen Abfrage ab

Beschreibung

Objektorientierter Stil

public mysqli::reap_async_query(): mysqli_result|bool

Prozeduraler Stil

mysqli_reap_async_query(mysqli $mysql): mysqli_result|bool

Ruft das Ergebnis einer asynchronen Abfrage ab.

Hinweis:

Nur in mysqlnd verfügbar.

Parameter-Liste

mysql

Nur bei prozeduralem Aufruf: ein von mysqli_connect() oder mysqli_init() zurückgegebenes mysqli-Objekt.

Rückgabewerte

Gibt bei einem Fehler false zurück. Bei erfolgreichen Abfragen, die eine Ergebnismenge erzeugen, also z. B. SELECT, SHOW, DESCRIBE oder EXPLAIN, gibt mysqli_reap_async_query() ein mysqli_result-Objekt zurück. Bei anderen erfolgreichen Abfragen gibt mysqli_reap_async_query() true zurück.

Fehler/Exceptions

If mysqli error reporting is enabled (MYSQLI_REPORT_ERROR) and the requested operation fails, a warning is generated. If, in addition, the mode is set to MYSQLI_REPORT_STRICT, a mysqli_sql_exception is thrown instead.

Siehe auch

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