function.db2-num-fields.html
来自「php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容」· HTML 代码 · 共 122 行
HTML
122 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Returns the number of fields contained in a 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-next-result.html">db2_next_result</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.db2-num-rows.html">db2_num_rows</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-num-fields" class="refentry"> <div class="refnamediv"> <h1 class="refname">db2_num_fields</h1> <p class="verinfo">(PECL ibm_db2:1.0-1.6.2)</p><p class="refpurpose"><span class="refname">db2_num_fields</span> — <span class="dc-title"> Returns the number of fields contained in a result set </span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">int</span> <span class="methodname"><b><b>db2_num_fields</b></b></span> ( <span class="methodparam"><span class="type">resource</span> <tt class="parameter">$stmt</tt></span> )</div> <p class="para rdfs-comment"> Returns the number of fields contained in a result set. This is most useful for handling the result sets returned by dynamically generated queries, or for result sets returned by stored procedures, where your application cannot otherwise know how to retrieve and use the results. </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 statement resource containing a result set. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns an integer value representing the number of fields in the result set associated with the specified statement resource. Returns <b><tt>FALSE</tt></b> if the statement resource is not a valid input value. </p> </div> <div class="refsect1 examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example"> <p><b>Example #1 Retrieving the number of fields in a result set</b></p> <div class="example-contents"><p> The following example demonstrates how to retrieve the number of fields returned in a result set. </p></div> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br /><br />$sql </span><span style="color: #007700">= </span><span style="color: #DD0000">"SELECT id, name, breed, weight FROM animals ORDER BY breed"</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">, </span><span style="color: #0000BB">$sql</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$columns </span><span style="color: #007700">= </span><span style="color: #0000BB">db2_num_fields</span><span style="color: #007700">(</span><span style="color: #0000BB">$stmt</span><span style="color: #007700">);<br /><br />echo </span><span style="color: #DD0000">"There are {$columns} columns in the result set."</span><span style="color: #007700">;<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>There are 4 columns in the result set.</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-execute.html" class="function" rel="rdfs-seeAlso">db2_execute()</a></li> <li class="member"><a href="function.db2-field-display-size.html" class="function" rel="rdfs-seeAlso">db2_field_display_size()</a></li> <li class="member"><a href="function.db2-field-name.html" class="function" rel="rdfs-seeAlso">db2_field_name()</a></li> <li class="member"><a href="function.db2-field-num.html" class="function" rel="rdfs-seeAlso">db2_field_num()</a></li> <li class="member"><a href="function.db2-field-precision.html" class="function" rel="rdfs-seeAlso">db2_field_precision()</a></li> <li class="member"><a href="function.db2-field-scale.html" class="function" rel="rdfs-seeAlso">db2_field_scale()</a></li> <li class="member"><a href="function.db2-field-type.html" class="function" rel="rdfs-seeAlso">db2_field_type()</a></li> <li class="member"><a href="function.db2-field-width.html" class="function" rel="rdfs-seeAlso">db2_field_width()</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-next-result.html">db2_next_result</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.db2-num-rows.html">db2_num_rows</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 + =
减小字号Ctrl + -
显示快捷键?