mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-18 05:26:57 +08:00
111 lines
6.3 KiB
HTML
111 lines
6.3 KiB
HTML
<!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.mysql-free-result" class="refentry">
|
||
<div class="refnamediv">
|
||
<h1 class="refname">mysql_free_result</h1>
|
||
<p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">mysql_free_result</span> — <span class="dc-title">释放结果内存</span></p>
|
||
|
||
</div>
|
||
<div class="refsect1 description" id="refsect1-function.mysql-free-result-description">
|
||
<h3 class="title">说明</h3>
|
||
<div class="methodsynopsis dc-description">
|
||
<span class="methodname"><strong>mysql_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>mysql_free_result()</strong></span> 将释放所有与结果标识符
|
||
<code class="parameter">result</code> 所关联的内存。
|
||
</p>
|
||
<p class="para">
|
||
<span class="function"><strong>mysql_free_result()</strong></span>
|
||
仅需要在考虑到返回很大的结果集时会占用多少内存时调用。在脚本结束后所有关联的内存都会被自动释放。
|
||
|
||
</p>
|
||
<p class="para">
|
||
成功时返回 <strong><code>TRUE</code></strong>, 或者在失败时返回 <strong><code>FALSE</code></strong>。
|
||
</p>
|
||
<p class="para">
|
||
为向下兼容仍然可以使用
|
||
<span class="function"><strong>mysql_freeresult()</strong></span>,但反对这样做。
|
||
</p>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 parameters" id="refsect1-function.mysql-free-result-parameters">
|
||
<h3 class="title">参数</h3>
|
||
<p class="para">
|
||
<dl>
|
||
|
||
<dt>
|
||
<code class="parameter">
|
||
result</code></dt>
|
||
<dd>
|
||
<p class="para"><span class="type"><a href="language.types.resource.html" class="type resource">resource</a></span>
|
||
型的结果集。此结果集来自对 <span class="function"><a href="mysql_query.html" class="function">mysql_query()</a></span>
|
||
的调用。</p></dd>
|
||
|
||
</dl>
|
||
|
||
</p>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 returnvalues" id="refsect1-function.mysql-free-result-returnvalues">
|
||
<h3 class="title">返回值</h3>
|
||
<p class="para">
|
||
成功时返回 <strong><code>TRUE</code></strong>, 或者在失败时返回 <strong><code>FALSE</code></strong>。
|
||
</p>
|
||
<p class="para">
|
||
If a non-resource is used for the <code class="parameter">result</code>, an
|
||
error of level E_WARNING will be emitted. It's worth noting that
|
||
<span class="function"><a href="mysql_query.html" class="function">mysql_query()</a></span> only returns a <span class="type"><a href="language.types.resource.html" class="type resource">resource</a></span>
|
||
for SELECT, SHOW, EXPLAIN, and DESCRIBE queries.
|
||
</p>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 examples" id="refsect1-function.mysql-free-result-examples">
|
||
<h3 class="title">范例</h3>
|
||
<p class="para">
|
||
<div class="example" id="example-2149">
|
||
<p><strong>Example #1 A <span class="function"><strong>mysql_free_result()</strong></span> example</strong></p>
|
||
<div class="example-contents">
|
||
<div class="phpcode"><pre><span style="color: #000000">
|
||
<span style="color: #0000BB"><?php<br />$result </span><span style="color: #007700">= </span><span style="color: #0000BB">mysql_query</span><span style="color: #007700">(</span><span style="color: #DD0000">"SELECT id,email FROM people WHERE id = '42'"</span><span style="color: #007700">);<br />if (!</span><span style="color: #0000BB">$result</span><span style="color: #007700">) {<br /> echo </span><span style="color: #DD0000">'Could not run query: ' </span><span style="color: #007700">. </span><span style="color: #0000BB">mysql_error</span><span style="color: #007700">();<br /> exit;<br />}<br /></span><span style="color: #FF8000">/* Use the result, assuming we're done with it afterwards */<br /></span><span style="color: #0000BB">$row </span><span style="color: #007700">= </span><span style="color: #0000BB">mysql_fetch_assoc</span><span style="color: #007700">(</span><span style="color: #0000BB">$result</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/* Now we free up the result and continue on with our script */<br /></span><span style="color: #0000BB">mysql_free_result</span><span style="color: #007700">(</span><span style="color: #0000BB">$result</span><span style="color: #007700">);<br /><br />echo </span><span style="color: #0000BB">$row</span><span style="color: #007700">[</span><span style="color: #DD0000">'id'</span><span style="color: #007700">];<br />echo </span><span style="color: #0000BB">$row</span><span style="color: #007700">[</span><span style="color: #DD0000">'email'</span><span style="color: #007700">];<br /></span><span style="color: #0000BB">?></span>
|
||
</span>
|
||
</pre></div>
|
||
</div>
|
||
|
||
</div>
|
||
</p>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 notes" id="refsect1-function.mysql-free-result-notes">
|
||
<h3 class="title">注释</h3>
|
||
<blockquote class="note"><p><strong class="note">Note</strong>:
|
||
<p class="para">
|
||
为了向下兼容,可以使用下列已废弃的别名:
|
||
<span class="function"><strong>mysql_freeresult()</strong></span>
|
||
</p>
|
||
</p></blockquote>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 seealso" id="refsect1-function.mysql-free-result-seealso">
|
||
<h3 class="title">参见</h3>
|
||
<p class="para">
|
||
<ul class="simplelist">
|
||
<li class="member"><span class="function"><a href="mysql_query.html" class="function" rel="rdfs-seeAlso">mysql_query()</a> - 发送一条 MySQL 查询</span></li>
|
||
<li class="member"><span class="function"><a href="is_resource.html" class="function" rel="rdfs-seeAlso">is_resource()</a> - 检测变量是否为资源类型</span></li>
|
||
</ul>
|
||
</p>
|
||
</div>
|
||
|
||
</div></div></div></body></html> |