function.ifx-fetch-row.html
来自「php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容」· HTML 代码 · 共 123 行
HTML
123 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Get row as an associative array</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.ifx-errormsg.html">ifx_errormsg</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.ifx-fieldproperties.html">ifx_fieldproperties</a></div> <div class="up"><a href="ref.ifx.html">Informix Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.ifx-fetch-row" class="refentry"> <div class="refnamediv"> <h1 class="refname">ifx_fetch_row</h1> <p class="verinfo">(No version information available, might be only in CVS)</p><p class="refpurpose"><span class="refname">ifx_fetch_row</span> — <span class="dc-title">Get row as an associative array</span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">array</span> <span class="methodname"><b><b>ifx_fetch_row</b></b></span> ( <span class="methodparam"><span class="type">resource</span> <tt class="parameter">$result_id</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">$position</tt></span> ] )</div> <p class="para rdfs-comment"> Fetches one row of data from the result associated with the specified result identifier. </p> <p class="para"> Subsequent calls to <b>ifx_fetch_row()</b> would return the next row in the result set, or <b><tt>FALSE</tt></b> if there are no more rows. </p> </div> <div class="refsect1 parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><i><tt class="parameter">result_id</tt></i></span> <dd> <p class="para"> <i><tt class="parameter">result_id</tt></i> is a valid resultid returned by <a href="function.ifx-query.html" class="function">ifx_query()</a> or <a href="function.ifx-prepare.html" class="function">ifx_prepare()</a> (select type queries only!). </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">position</tt></i></span> <dd> <p class="para"> An optional parameter for a "fetch" operation on "scroll" cursors: <i>NEXT</i>, <i>PREVIOUS</i>, <i>CURRENT</i>, <i>FIRST</i>, <i>LAST</i> or a number. If you specify a number, an "absolute" row fetch is executed. This parameter is optional, and only valid for SCROLL cursors. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns an associative array that corresponds to the fetched row, or <b><tt>FALSE</tt></b> if there are no more rows. </p> <p class="para"> Blob columns are returned as integer blob id values for use in <a href="function.ifx-get-blob.html" class="function">ifx_get_blob()</a> unless you have used ifx_textasvarchar(1) or ifx_byteasvarchar(1), in which case blobs are returned as string values. </p> </div> <div class="refsect1 examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example"> <p><b>Example #1 Informix fetch rows</b></p> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br />$rid </span><span style="color: #007700">= </span><span style="color: #0000BB">ifx_prepare </span><span style="color: #007700">(</span><span style="color: #DD0000">"select * from emp where name like " </span><span style="color: #007700">. </span><span style="color: #0000BB">$name</span><span style="color: #007700">,<br /> </span><span style="color: #0000BB">$connid</span><span style="color: #007700">, </span><span style="color: #0000BB">IFX_SCROLL</span><span style="color: #007700">);<br />if (! </span><span style="color: #0000BB">$rid</span><span style="color: #007700">) {<br /> </span><span style="color: #FF8000">/* ... error ... */<br /></span><span style="color: #007700">}<br /></span><span style="color: #0000BB">$rowcount </span><span style="color: #007700">= </span><span style="color: #0000BB">ifx_affected_rows</span><span style="color: #007700">(</span><span style="color: #0000BB">$rid</span><span style="color: #007700">);<br />if (</span><span style="color: #0000BB">$rowcount </span><span style="color: #007700">> </span><span style="color: #0000BB">1000</span><span style="color: #007700">) {<br /> </span><span style="color: #0000BB">printf </span><span style="color: #007700">(</span><span style="color: #DD0000">"Too many rows in result set (%d)\n<br />"</span><span style="color: #007700">, </span><span style="color: #0000BB">$rowcount</span><span style="color: #007700">);<br /> die (</span><span style="color: #DD0000">"Please restrict your query<br />\n"</span><span style="color: #007700">);<br />}<br />if (! </span><span style="color: #0000BB">ifx_do </span><span style="color: #007700">(</span><span style="color: #0000BB">$rid</span><span style="color: #007700">)) {<br /> </span><span style="color: #FF8000">/* ... error ... */<br /></span><span style="color: #007700">}<br /></span><span style="color: #0000BB">$row </span><span style="color: #007700">= </span><span style="color: #0000BB">ifx_fetch_row </span><span style="color: #007700">(</span><span style="color: #0000BB">$rid</span><span style="color: #007700">, </span><span style="color: #DD0000">"NEXT"</span><span style="color: #007700">);<br />while (</span><span style="color: #0000BB">is_array</span><span style="color: #007700">(</span><span style="color: #0000BB">$row</span><span style="color: #007700">)) {<br /> for (</span><span style="color: #0000BB">reset</span><span style="color: #007700">(</span><span style="color: #0000BB">$row</span><span style="color: #007700">); </span><span style="color: #0000BB">$fieldname</span><span style="color: #007700">=</span><span style="color: #0000BB">key</span><span style="color: #007700">(</span><span style="color: #0000BB">$row</span><span style="color: #007700">); </span><span style="color: #0000BB">next</span><span style="color: #007700">(</span><span style="color: #0000BB">$row</span><span style="color: #007700">)) {<br /> </span><span style="color: #0000BB">$fieldvalue </span><span style="color: #007700">= </span><span style="color: #0000BB">$row</span><span style="color: #007700">[</span><span style="color: #0000BB">$fieldname</span><span style="color: #007700">];<br /> </span><span style="color: #0000BB">printf </span><span style="color: #007700">(</span><span style="color: #DD0000">"%s = %s,"</span><span style="color: #007700">, </span><span style="color: #0000BB">$fieldname</span><span style="color: #007700">, </span><span style="color: #0000BB">$fieldvalue</span><span style="color: #007700">);<br /> }<br /> </span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"\n<br />"</span><span style="color: #007700">);<br /> </span><span style="color: #0000BB">$row </span><span style="color: #007700">= </span><span style="color: #0000BB">ifx_fetch_row</span><span style="color: #007700">(</span><span style="color: #0000BB">$rid</span><span style="color: #007700">, </span><span style="color: #DD0000">"NEXT"</span><span style="color: #007700">);<br />}<br /></span><span style="color: #0000BB">ifx_free_result </span><span style="color: #007700">(</span><span style="color: #0000BB">$rid</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span></span></code></div> </div> </div> </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.ifx-errormsg.html">ifx_errormsg</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.ifx-fieldproperties.html">ifx_fieldproperties</a></div> <div class="up"><a href="ref.ifx.html">Informix Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?