釋放結果記憶體

mysql_free_result

(PHP 4, PHP 5)

mysql_free_result釋放結果記憶體

說明

mysql_free_result(resource $result): bool

mysql_free_result() 將釋放所有與結果識別符號 result 所關聯的記憶體。

mysql_free_result() 僅需要在考慮到返回很大的結果集時會佔用多少記憶體時呼叫。在指令碼結束后所有關聯的記憶體都會被自動釋放。

成功時返回 true, 或者在失敗時返回 false

為向下相容仍然可以使用 mysql_freeresult(),但反對這樣做。

參數

result

resource 型的結果集。此結果集來自對 mysql_query() 的呼叫。

返回值

成功時返回 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.

範例

示例 #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'];
?>

註釋

注意:

爲了向下相容,可以使用下列已廢棄的別名: mysql_freeresult()

參見

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *