Example 1 — Detect Extra Results After Multi Query
Run two statements and check whether more results remain after the first.
<?php
$mysqli = mysqli_connect("localhost", "demo_user", "demo_pass", "app_db");
mysqli_multi_query($mysqli, "SELECT 1; SELECT 2;");
$result = mysqli_store_result($mysqli);
if ($result) {
mysqli_free_result($result);
}
echo mysqli_more_results($mysqli) ? "More waiting." : "Done.", PHP_EOL;
mysqli_close($mysqli); How It Works
- mysqli_multi_query() sends two SELECTs at once.
- store_result() reads the first result set.
- mysqli_more_results() is still true because SELECT 2 is pending.
- You must call next_result() before reading the second set.

