PHP7占用内存,释放查询结果占用的内存 - PHP 7 中文文档

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

pg_free_result – 释放查询结果占用的内存

说明

pg_free_result

( resource $result

) : bool

pg_free_result() 仅在当你担心脚本执行时占用了过多内存时调用。脚本执行完毕后所有的查询结果占用的内存都会被自动释放。不过如果你确认在脚本中不会再用到查询结果了,你可以用 result 作为参数调用 pg_free_result() 来释放有关的内存。成功时返回 TRUE, 或者在失败时返回 FALSE。

Note:

本函数以前的名字为 pg_freeresult()。

参见 [pg_query()](php7/function.pg-query)。

参数

result

PostgreSQL query result resource, returned by [pg_query()](php7/function.pg-query),

[pg_query_params()](php7/function.pg-query-params) or [pg_execute()](php7/function.pg-execute)

(among others).

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE。

范例

Example #1 pg_free_result() example

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

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

$val = pg_fetch_result($res, 1, 0);

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

pg_free_result($res);

?>

以上例程会输出:

First field in the second row is: 2

参见

[pg_query()](php7/function.pg-query) – 执行查询

[pg_query_params()](php7/function.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()](php7/function.pg-execute) – Sends a request to execute a prepared statement with given parameters, and waits for the result

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值