Db free result: Difference between revisions From Online Manual

Jump to: navigation, search
No edit summary
No edit summary
 
(5 intermediate revisions by 3 users not shown)
Line 3: Line 3:
|order_position=5
|order_position=5
|usage=$smcFunc['db_free_result'] (result)  
|usage=$smcFunc['db_free_result'] (result)  
|description=works exactly as [http://php.net/mysql_free_result mysql_free_result], the function will free the memory used by the recourse $result.
|description=Frees the memory in use by the result from a query. Works exactly as [http://php.net/mysql_free_result mysql_free_result]. This is usually called after the data has been fetched from the database.
|parameters={{parmdesc
|parameters={{parmdesc
   |result|d1=a query resource as returned by [[db_query]].
   |result|d1=a query resource as returned by [[db_query]].
}}
}}
|return=will return the exact same results as [http://php.net/mysql_free_result mysql_free_result].
|return=will return the exact same results as [http://php.net/mysql_free_result mysql_free_result].
|example=<nowiki>$smcFunc['db_free_result']($request);</nowiki>
|example=<nowiki>// Grab a result from the database.
$result = $smcFunc['db_query']('', '
SELECT something
FROM {db_prefix}a_table', array());
 
// Fetch the data from it.
$array = array();
while ($data = $smcFunc['db_fetch_assoc']($result))
$array[] = $data;
 
// Then free the result.
$smcFunc['db_free_result']($request);</nowiki>
}}
}}
<noinclude>
<noinclude>
[[Category:Database Functions]]
[[Category:Database Functions]]</noinclude>
[[Category:2.0]]
[[Category:Customizing SMF]]
[[Category:Developing SMF]]</noinclude>

Latest revision as of 16:00, 4 November 2012

Usage:

$smcFunc['db_free_result'] (result)


Description: Frees the memory in use by the result from a query. Works exactly as mysql_free_result. This is usually called after the data has been fetched from the database.

Parameters:

  • result a query resource as returned by db_query.

Return: will return the exact same results as mysql_free_result.

Example:

// Grab a result from the database.
$result = $smcFunc['db_query']('', '
	SELECT something
	FROM {db_prefix}a_table', array());

// Fetch the data from it.
$array = array();
while ($data = $smcFunc['db_fetch_assoc']($result))
	$array[] = $data;

// Then free the result.
$smcFunc['db_free_result']($request);



Advertisement: