Name

mysql_unbuffered_query( )

Synopsis

mysql_unbuffered_query(sql_statement[, connection])

Use this to execute an SQL statement given without buffering the results so that you can retrieve the data without having to wait for the results set to be completed. An identifier may be given as a second argument to the function to interface with a different connection. The function returns false if the query is unsuccessful. For SQL statements that would not return a results set based on their nature (e.g., INSERT), true is returned when the function is successful. This function should be used with care, because an enormous results set could overwhelm the program’s allocated memory.

...
$sql_stmnt = "SELECT wrid, client_name, description
              FROM workreq, clients
              WHERE workreq.clientid = clients.clientid";
$results = mysql_unbuffered_query($sql_stmnt, $connection);
while($row = mysql_fetch_row($results)) {
  print "WR-$row[0]: $row[1] - $row[2] \n";
}
...

There’s no difference in the syntax for mysql_unbuffered_query() and mysql_query( ), nor in the handling of the results. The only differences in this function are the speed for large databases and the fact that functions such as mysql_num_row( ) and mysql_data_seek() cannot be used, because the results set is not buffered and therefore cannot be analyzed by these functions.

Get MySQL in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.