(Better example) |
No edit summary |
||
(One intermediate revision by the same user 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]. | |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>$result = $smcFunc['db_query']('', ' | |example=<nowiki>// Grab a result from the database. | ||
$result = $smcFunc['db_query']('', ' | |||
SELECT something | SELECT something | ||
FROM {db_prefix}a_table', array()); | FROM {db_prefix}a_table', array()); | ||
// Fetch the data from it. | |||
$array = array(); | $array = array(); | ||
while ($data = $smcFunc['db_fetch_assoc']($result)) | while ($data = $smcFunc['db_fetch_assoc']($result)) | ||
$array[] = $data; | $array[] = $data; | ||
// Then free the result. | |||
$smcFunc['db_free_result']($request);</nowiki> | $smcFunc['db_free_result']($request);</nowiki> | ||
}} | }} | ||
<noinclude> | <noinclude> | ||
[[Category:Database Functions]]</noinclude> | [[Category:Database Functions]]</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);