uTools-Manuals/docs/php/pg_free_result.html
2019-04-28 19:00:34 +08:00

102 lines
6.1 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>释放查询结果占用的内存</title>
</head>
<body class="docs"><div id="layout">
<div id="layout-content"><div id="function.pg-free-result" class="refentry">
<div class="refnamediv">
<h1 class="refname">pg_free_result</h1>
<p class="verinfo">(PHP 4 &gt;= 4.2.0, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">pg_free_result</span> &mdash; <span class="dc-title">释放查询结果占用的内存</span></p>
</div>
<div class="refsect1 description" id="refsect1-function.pg-free-result-description">
<h3 class="title">说明</h3>
<div class="methodsynopsis dc-description">
<span class="methodname"><strong>pg_free_result</strong></span>
( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$result</code></span>
) : <span class="type">bool</span></div>
<p class="para rdfs-comment">
<span class="function"><strong>pg_free_result()</strong></span> 仅在当你担心脚本执行时占用了过多内存时调用。脚本执行完毕后所有的查询结果占用的内存都会被自动释放。不过如果你确认在脚本中不会再用到查询结果了,你可以用 <code class="parameter">result</code> 作为参数调用 <span class="function"><strong>pg_free_result()</strong></span> 来释放有关的内存。成功时返回 <strong><code>TRUE</code></strong> 或者在失败时返回 <strong><code>FALSE</code></strong>
</p>
<blockquote class="note"><p><strong class="note">Note</strong>:
<p class="para">
本函数以前的名字为 <em>pg_freeresult()</em>
</p>
</p></blockquote>
<p class="para">
参见 <span class="function"><a href="pg_query.html" class="function">pg_query()</a></span>
</p>
</div>
<div class="refsect1 parameters" id="refsect1-function.pg-free-result-parameters">
<h3 class="title">参数</h3>
<p class="para">
<dl>
<dt>
<code class="parameter">result</code></dt>
<dd>
<p class="para">
PostgreSQL query result resource, returned by <span class="function"><a href="pg_query.html" class="function">pg_query()</a></span>,
<span class="function"><a href="pg_query_params.html" class="function">pg_query_params()</a></span> or <span class="function"><a href="pg_execute.html" class="function">pg_execute()</a></span>
(among others).
</p>
</dd>
</dl>
</p>
</div>
<div class="refsect1 returnvalues" id="refsect1-function.pg-free-result-returnvalues">
<h3 class="title">返回值</h3>
<p class="para">
成功时返回 <strong><code>TRUE</code></strong> 或者在失败时返回 <strong><code>FALSE</code></strong>
</p>
</div>
<div class="refsect1 examples" id="refsect1-function.pg-free-result-examples">
<h3 class="title">范例</h3>
<p class="para">
<div class="example" id="example-2497">
<p><strong>Example #1 <span class="function"><strong>pg_free_result()</strong></span> example</strong></p>
<div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$db&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">pg_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">"dbname=users&nbsp;user=me"</span><span style="color: #007700">)&nbsp;||&nbsp;die();<br /><br /></span><span style="color: #0000BB">$res&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">pg_query</span><span style="color: #007700">(</span><span style="color: #0000BB">$db</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"SELECT&nbsp;1&nbsp;UNION&nbsp;ALL&nbsp;SELECT&nbsp;2"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$val&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">pg_fetch_result</span><span style="color: #007700">(</span><span style="color: #0000BB">$res</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">);<br /><br />echo&nbsp;</span><span style="color: #DD0000">"First&nbsp;field&nbsp;in&nbsp;the&nbsp;second&nbsp;row&nbsp;is:&nbsp;"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">pg_free_result</span><span style="color: #007700">(</span><span style="color: #0000BB">$res</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
</div>
<div class="example-contents"><p>以上例程会输出:</p></div>
<div class="example-contents screen">
<div class="cdata"><pre>
First field in the second row is: 2
</pre></div>
</div>
</div>
</p>
</div>
<div class="refsect1 seealso" id="refsect1-function.pg-free-result-seealso">
<h3 class="title">参见</h3>
<p class="para">
<ul class="simplelist">
<li class="member"><span class="function"><a href="pg_query.html" class="function" rel="rdfs-seeAlso">pg_query()</a> - 执行查询</span></li>
<li class="member"><span class="function"><a href="pg_query_params.html" class="function" rel="rdfs-seeAlso">pg_query_params()</a> - Submits a command to the server and waits for the result, with the ability to pass parameters separately from the SQL command text</span></li>
<li class="member"><span class="function"><a href="pg_execute.html" class="function" rel="rdfs-seeAlso">pg_execute()</a> - Sends a request to execute a prepared statement with given parameters, and waits for the result</span></li>
</ul>
</p>
</div>
</div></div></div></body></html>