(PHP 4, PHP 5)
mysql_free_result — 釋放結(jié)果內(nèi)存
說明
bool mysql_free_result ( resource$result
)
mysql_free_result() 將釋放所有與結(jié)果標(biāo)識符
result
所關(guān)聯(lián)的內(nèi)存。
mysql_free_result() 僅需要在考慮到返回很大的結(jié)果集時會占用多少內(nèi)存時調(diào)用。在腳本結(jié)束后所有關(guān)聯(lián)的內(nèi)存都會被自動釋放。
成功時返回 TRUE
, 或者在失敗時返回 FALSE
。
為向下兼容仍然可以使用 mysql_freeresult(),但反對這樣做。
參數(shù)
result
resource 型的結(jié)果集。此結(jié)果集來自對 mysql_query() 的調(diào)用。
返回值
成功時返回 TRUE
, 或者在失敗時返回 FALSE
。
If a non-resource is used for the result
, an
error of level E_WARNING will be emitted. It's worth noting that
mysql_query() only returns a resource
for SELECT, SHOW, EXPLAIN, and DESCRIBE queries.
范例
Example #1 A mysql_free_result() example
<?php
$result = mysql_query("SELECT id,email FROM people WHERE id = '42'");
if (!$result) {
echo 'Could not run query: ' . mysql_error();
exit;
}
/* Use the result, assuming we're done with it afterwards */
$row = mysql_fetch_assoc($result);
/* Now we free up the result and continue on with our script */
mysql_free_result($result);
echo $row['id'];
echo $row['email'];
?>
注釋
Note:
為了向下兼容,可以使用下列已廢棄的別名: mysql_freeresult()
參見
mysql_query() - 發(fā)送一條 MySQL 查詢 is_resource() - 檢測變量是否為資源類型