pg_free_result

(PHP 4 >= 4.2.0, PHP 5, PHP 7, PHP 8)

pg_free_result釋放查詢結(jié)果占用的內(nèi)存

說(shuō)明

pg_free_result(resource $result): bool

pg_free_result() 僅在當(dāng)你擔(dān)心腳本執(zhí)行時(shí)占用了過(guò)多內(nèi)存時(shí)調(diào)用。腳本執(zhí)行完畢后所有的查詢結(jié)果占用的內(nèi)存都會(huì)被自動(dòng)釋放。不過(guò)如果你確認(rèn)在腳本中不會(huì)再用到查詢結(jié)果了,你可以用 result 作為參數(shù)調(diào)用 pg_free_result() 來(lái)釋放有關(guān)的內(nèi)存。成功時(shí)返回 true, 或者在失敗時(shí)返回 false。

注意:

本函數(shù)以前的名字為 pg_freeresult()

參見(jiàn) pg_query()。

參數(shù)

result

PostgreSQL query result resource, returned by pg_query(), pg_query_params() or pg_execute() (among others).

返回值

成功時(shí)返回 true, 或者在失敗時(shí)返回 false。

范例

示例 #1 pg_free_result() example

<?php
$db 
pg_connect("dbname=users user=me") || die();

$res pg_query($db"SELECT 1 UNION ALL SELECT 2");

$val pg_fetch_result($res10);

echo 
"First field in the second row is: "$val"\n";

pg_free_result($res);
?>

以上例程會(huì)輸出:

First field in the second row is: 2

參見(jiàn)

  • pg_query() - 執(zhí)行查詢
  • pg_query_params() - Submits a command to the server and waits for the result, with the ability to pass parameters separately from the SQL command text
  • pg_execute() - Sends a request to execute a prepared statement with given parameters, and waits for the result