mysql_store_result() retrieves and stores a result set.
Syntax
MYSQL_RES *
mysql_store_result(MYSQL *mysql)
Return values
A pointer that points to a MYSQL_RES structure with results. If the statement does not return a result set or an error occurs, NULL is returned.
To determine whether an error has occurred, check whether mysql_error() returns a non-empty string, whether mysql_errno() returns a non-zero value, or whether mysql_field_count() returns zero.
Error messages
If mysql_store_result() is executed, it resets mysql_error() and mysql_errno().
CR_COMMANDS_OUT_OF_SYNC: Commands are executed in an incorrect order.CR_OUT_OF_MEMORY: The memory is insufficient.CR_SERVER_GONE_ERROR: The connection to the OBServer was interrupted.CR_SERVER_LOST: The connection to the server was lost during the query.CR_UNKNOWN_ERROR: An unknown error occurred.
Notes
After you call mysql_real_query() or mysql_query(), you must call mysql_store_result() or mysql_use_result() for each of the following statement that generates a result set: SELECT, SHOW, DESCRIBE, EXPLAIN, and CHECK TABLE. After you process the result set, you must call mysql_free_result().
You do not need to call mysql_store_result() or mysql_use_result() for other statements. However, even if you call mysql_store_result() in any cases, it does not cause any harm or significant performance degradation. You can check whether mysql_store_result() returns a non-zero value to determine whether the statement generates a result set.
If multi-statement support is enabled, you must retrieve the results of calling mysql_real_query() or mysql_query() by calling mysql_next_result() in a loop to determine whether more results are generated.
mysql_store_result() reads the entire result of a query to the client, assigns a MYSQL_RES structure, and puts the result into the structure.
If an statement, such as INSERT, does not return a result set, or an error occurs and reading of the result set fails, mysql_store_result() returns NULL.
If no rows are returned, an empty result set is returned. An empty result set is different from a null pointer as a return value.
After you call mysql_store_result() and obtain a result that is not a null pointer, you can call mysql_num_rows() to find out the number of rows in the result set.
You can call mysql_fetch_row() to obtain rows from the result set or call mysql_row_seek() and mysql_row_tell() to obtain or set the current row position in the result set.