Everyone is familiar with mysql_query, so let's briefly introduce the mysql_unbuffered_query
mysql_unbuffered_query
(PHP 4 >= 4.0.6, PHP 5) mysql_unbuffered_query -- Sends a SQL query to MySQL without fetching and caching the resulting rows
Description resource mysql_unbuffered_query ( string query [, resource link_identifier] )
mysql_unbuffered_query() sends a SQL query query to MySQL, but doesn't automatically fetch and cache the result set like mysql_query(). On the one hand, this saves considerable memory when working with large result sets. On the other hand, you can manipulate the result set as soon as you get the first row, rather than waiting for the entire SQL statement to be executed. When using multiple database connections, you must specify the optional parameter link_identifier.
Note: The benefits of mysql_unbuffered_query() come at a cost: you can't use mysql_num_rows() and mysql_data_seek() on top of the result set returned by mysql_unbuffered_query(). In addition, before sending a new SQL query to MySQL, all uncached SQL queries must be extracted from the resulting rows.
The above is the explanation of mysql_unbuffered_query in the php manual, I searched a lot of explanations for the explanations already in the manual on the Internet, many people hope to have an example to better understand the application of this function, I followed the explanation given, made an example, for reference only:
|