odbc_free_result

(PHP 3 >= 3.0.6, PHP 4, PHP 5)

odbc_free_result -- Free resources associated with a result

Description

bool odbc_free_result ( resource result_id )

Always returns TRUE.

odbc_free_result() only needs to be called if you are worried about using too much memory while your script is running. All result memory will automatically be freed when the script is finished. But, if you are sure you are not going to need the result data anymore in a script, you may call odbc_free_result(), and the memory associated with result_id will be freed.

注: If auto-commit is disabled (see odbc_autocommit()) and you call odbc_free_result() before committing, all pending transactions are rolled back.


add a note add a note User Contributed Notes
rich at kastle dot com
20-Dec-2004 07:48
("Note:  If auto-commit is disabled (see odbc_autocommit()) and you call odbc_free_result() before committing, all pending transactions are rolled back.")

I've looked thru the code, and that note is definitely wrong, at least in my environment (Windows/SQL Server).  odbc_free_result ultimately just calls SQLFreeStmt which has NO EFFECT on outstanding transactions.

In fact, it seems it must be wrong for all environments, because the SQLFreeStmt is bound to the destruction of the result resource.  So unset($result) would be just as dangerous - and you're randomly and unpredictably screwed if garbage collection reaps the result set before your transaction's done.
rogersd at island dot net
06-Sep-2001 11:03
odbc_free_result() is also the way to avoid the dreaded "Too many open cursor" error.