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

125 lines
7.1 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>Returns a single column from a row in the result set</title>
</head>
<body class="docs"><div id="layout">
<div id="layout-content"><div id="function.db2-result" class="refentry">
<div class="refnamediv">
<h1 class="refname">db2_result</h1>
<p class="verinfo">(PECL ibm_db2 &gt;= 1.0.0)</p><p class="refpurpose"><span class="refname">db2_result</span> &mdash; <span class="dc-title">
Returns a single column from a row in the result set
</span></p>
</div>
<div class="refsect1 description" id="refsect1-function.db2-result-description">
<h3 class="title">说明</h3>
<div class="methodsynopsis dc-description">
<span class="methodname"><strong>db2_result</strong></span>
( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$stmt</code></span>
, <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$column</code></span>
) : <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span></div>
<p class="para rdfs-comment">
Use <span class="function"><strong>db2_result()</strong></span> to return the value of a specified
column in the current row of a result set. You must call
<span class="function"><a href="db2_fetch_row.html" class="function">db2_fetch_row()</a></span> before calling
<span class="function"><strong>db2_result()</strong></span> to set the location of the result set
pointer.
</p>
</div>
<div class="refsect1 parameters" id="refsect1-function.db2-result-parameters">
<h3 class="title">参数</h3>
<p class="para">
<dl>
<dt>
<code class="parameter">stmt</code></dt>
<dd>
<p class="para">
A valid <em>stmt</em> resource.
</p>
</dd>
<dt>
<code class="parameter">column</code></dt>
<dd>
<p class="para">
Either an integer mapping to the 0-indexed field in the result set, or
a string matching the name of the column.
</p>
</dd>
</dl>
</p>
</div>
<div class="refsect1 returnvalues" id="refsect1-function.db2-result-returnvalues">
<h3 class="title">返回值</h3>
<p class="para">
Returns the value of the requested field if the field exists in the result
set. Returns NULL if the field does not exist, and issues a warning.
</p>
</div>
<div class="refsect1 examples" id="refsect1-function.db2-result-examples">
<h3 class="title">范例</h3>
<p class="para">
<div class="example" id="example-1271">
<p><strong>Example #1 A <span class="function"><strong>db2_result()</strong></span> example</strong></p>
<div class="example-contents"><p>
The following example demonstrates how to iterate through a result set
with <span class="function"><a href="db2_fetch_row.html" class="function">db2_fetch_row()</a></span> and retrieve columns from the
result set with <span class="function"><strong>db2_result()</strong></span>.
</p></div>
<div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$sql&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'SELECT&nbsp;name,&nbsp;breed&nbsp;FROM&nbsp;animals&nbsp;WHERE&nbsp;weight&nbsp;&lt;&nbsp;?'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$stmt&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">db2_prepare</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$sql</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">db2_execute</span><span style="color: #007700">(</span><span style="color: #0000BB">$stmt</span><span style="color: #007700">,&nbsp;array(</span><span style="color: #0000BB">10</span><span style="color: #007700">));<br />while&nbsp;(</span><span style="color: #0000BB">db2_fetch_row</span><span style="color: #007700">(</span><span style="color: #0000BB">$stmt</span><span style="color: #007700">))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$name&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">db2_result</span><span style="color: #007700">(</span><span style="color: #0000BB">$stmt</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$breed&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">db2_result</span><span style="color: #007700">(</span><span style="color: #0000BB">$stmt</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'BREED'</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;print&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #0000BB">$name</span><span style="color: #DD0000">&nbsp;</span><span style="color: #0000BB">$breed</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br />}<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>
cat Pook
gold fish Bubbles
budgerigar Gizmo
goat Rickety Ride
</pre></div>
</div>
</div>
</p>
</div>
<div class="refsect1 seealso" id="refsect1-function.db2-result-seealso">
<h3 class="title">参见</h3>
<p class="para">
<ul class="simplelist">
<li class="member"><span class="function"><a href="db2_fetch_array.html" class="function" rel="rdfs-seeAlso">db2_fetch_array()</a> - Returns an array, indexed by column position, representing a row in a result set</span></li>
<li class="member"><span class="function"><a href="db2_fetch_assoc.html" class="function" rel="rdfs-seeAlso">db2_fetch_assoc()</a> - Returns an array, indexed by column name, representing a row in a result set</span></li>
<li class="member"><span class="function"><a href="db2_fetch_both.html" class="function" rel="rdfs-seeAlso">db2_fetch_both()</a> - Returns an array, indexed by both column name and position, representing a row in a result set</span></li>
<li class="member"><span class="function"><a href="db2_fetch_object.html" class="function" rel="rdfs-seeAlso">db2_fetch_object()</a> - Returns an object with properties representing columns in the fetched row</span></li>
<li class="member"><span class="function"><a href="db2_fetch_row.html" class="function" rel="rdfs-seeAlso">db2_fetch_row()</a> - Sets the result set pointer to the next row or requested row</span></li>
</ul>
</p>
</div>
</div></div></div></body></html>