📄 function.db2-result.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Returns a single column from a row in the result set</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.db2-procedures.html">db2_procedures</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.db2-rollback.html">db2_rollback</a></div> <div class="up"><a href="ref.ibm-db2.html">IBM DB2 Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.db2-result" class="refentry"> <div class="refnamediv"> <h1 class="refname">db2_result</h1> <p class="verinfo">(PECL ibm_db2:1.0-1.6.2)</p><p class="refpurpose"><span class="refname">db2_result</span> — <span class="dc-title"> Returns a single column from a row in the result set </span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <span class="methodname"><b><b>db2_result</b></b></span> ( <span class="methodparam"><span class="type">resource</span> <tt class="parameter">$stmt</tt></span> , <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <tt class="parameter">$column</tt></span> )</div> <p class="para rdfs-comment"> Use <b>db2_result()</b> to return the value of a specified column in the current row of a result set. You must call <a href="function.db2-fetch-row.html" class="function">db2_fetch_row()</a> before calling <b>db2_result()</b> to set the location of the result set pointer. </p> </div> <div class="refsect1 parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><i><tt class="parameter">stmt</tt></i></span> <dd> <p class="para"> A valid <i>stmt</i> resource. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">column</tt></i></span> <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> </dt> </dl> </p> </div> <div class="refsect1 returnvalues"> <h3 class="title">Return Values</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"> <h3 class="title">Examples</h3> <p class="para"> <div class="example"> <p><b>Example #1 A <b>db2_result()</b> example</b></p> <div class="example-contents"><p> The following example demonstrates how to iterate through a result set with <a href="function.db2-fetch-row.html" class="function">db2_fetch_row()</a> and retrieve columns from the result set with <b>db2_result()</b>. </p></div> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br />$sql </span><span style="color: #007700">= </span><span style="color: #DD0000">'SELECT name, breed FROM animals WHERE weight < ?'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$stmt </span><span style="color: #007700">= </span><span style="color: #0000BB">db2_prepare</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">, </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">, array(</span><span style="color: #0000BB">10</span><span style="color: #007700">));<br />while (</span><span style="color: #0000BB">db2_fetch_row</span><span style="color: #007700">(</span><span style="color: #0000BB">$stmt</span><span style="color: #007700">)) {<br /> </span><span style="color: #0000BB">$name </span><span style="color: #007700">= </span><span style="color: #0000BB">db2_result</span><span style="color: #007700">(</span><span style="color: #0000BB">$stmt</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">);<br /> </span><span style="color: #0000BB">$breed </span><span style="color: #007700">= </span><span style="color: #0000BB">db2_result</span><span style="color: #007700">(</span><span style="color: #0000BB">$stmt</span><span style="color: #007700">, </span><span style="color: #DD0000">'BREED'</span><span style="color: #007700">);<br /> print </span><span style="color: #DD0000">"$name $breed"</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?></span></span></code></div> </div> <div class="example-contents"><p>The above example will output:</p></div> <div class="example-contents"><pre><div class="cdata"><pre>cat Pookgold fish Bubblesbudgerigar Gizmogoat Rickety Ride</pre></div> </pre></div> </div> </p> </div> <div class="refsect1 seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"><a href="function.db2-fetch-array.html" class="function" rel="rdfs-seeAlso">db2_fetch_array()</a></li> <li class="member"><a href="function.db2-fetch-assoc.html" class="function" rel="rdfs-seeAlso">db2_fetch_assoc()</a></li> <li class="member"><a href="function.db2-fetch-both.html" class="function" rel="rdfs-seeAlso">db2_fetch_both()</a></li> <li class="member"><a href="function.db2-fetch-object.html" class="function" rel="rdfs-seeAlso">db2_fetch_object()</a></li> <li class="member"><a href="function.db2-fetch-row.html" class="function" rel="rdfs-seeAlso">db2_fetch_row()</a></li> </ul> </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.db2-procedures.html">db2_procedures</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.db2-rollback.html">db2_rollback</a></div> <div class="up"><a href="ref.ibm-db2.html">IBM DB2 Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -