Current Location: Home> Latest Articles> What are the differences between mysqli_stmt::next_result and mysqli::more_results? How are they related?

What are the differences between mysqli_stmt::next_result and mysqli::more_results? How are they related?

gitbox 2025-09-22

In the MySQLi extension of PHP, mysqli_stmt::next_result and mysqli::more_results are both related to multi-query operations, but they are used in different scenarios and on different objects.

1. mysqli_stmt::next_result

This method is used with a mysqli_stmt object, which represents a prepared statement in MySQLi. When you execute multiple SQL queries in a single request, you need to move through the result sets returned from each query. mysqli_stmt::next_result is specifically used to advance to the next result set after processing the current one.

2. mysqli::more_results

This method is used with a mysqli object, which represents the connection to the MySQL server. mysqli::more_results checks if there are any remaining result sets from multi-query execution that have not been processed yet. It returns true if there are more results available, otherwise false.

In the example above, more_results() checks if there are any unprocessed result sets, while next_result() moves to the next result set and makes it available for further processing.