function.ifx-query.html

来自「php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容」· HTML 代码 · 共 187 行

HTML
187
字号
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head>  <title>Send Informix query</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-prepare.html">ifx_prepare</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.ifx-textasvarchar.html">ifx_textasvarchar</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-query" class="refentry"> <div class="refnamediv">  <h1 class="refname">ifx_query</h1>  <p class="verinfo">(No version information available, might be only in CVS)</p><p class="refpurpose"><span class="refname">ifx_query</span> &mdash; <span class="dc-title">Send Informix query</span></p> </div>  <div class="refsect1 description">  <h3 class="title">Description</h3>  <div class="methodsynopsis dc-description">   <span class="type">resource</span> <span class="methodname"><b><b>ifx_query</b></b></span>    ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$query</tt></span>   , <span class="methodparam"><span class="type">resource</span> <tt class="parameter">$link_identifier</tt></span>   [, <span class="methodparam"><span class="type">int</span> <tt class="parameter">$cursor_type</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">$blobidarray</tt></span>  ]] )</div>  <p class="para rdfs-comment">   Sends a <i><tt class="parameter">query</tt></i> to the currently active database on   the server that&#039;s associated with the specified link identifier.  </p>  <p class="para">   For &quot;select-type&quot; queries a cursor is declared and opened.   Non-select queries are &quot;execute immediate&quot;.  </p>  <p class="para">   For either query type the number of (estimated or real) affected rows is   saved for retrieval by <a href="function.ifx-affected-rows.html" class="function">ifx_affected_rows()</a>.  </p>  <p class="para">   If the contents of the TEXT (or BYTE) column allow it, you can also use   <i>ifx_textasvarchar(1)</i> and    <i>ifx_byteasvarchar(1)</i>.  This allows you to treat TEXT   (or BYTE) columns just as if they were ordinary (but long) VARCHAR columns   for select queries, and you don&#039;t need to bother with blob id&#039;s.  </p>  <p class="para">   With <i>ifx_textasvarchar(0)</i> or    <i>ifx_byteasvarchar(0)</i> (the default situation), select   queries will return BLOB columns as blob id&#039;s (integer value).  You can   get the value of the blob as a string or file with the blob functions (see   below).  </p> </div> <div class="refsect1 parameters">  <h3 class="title">Parameters</h3>  <p class="para">   <dl>    <dt>     <span class="term"><i><tt class="parameter">query</tt></i></span>     <dd>      <p class="para">       The query string.      </p>     </dd>    </dt>    <dt>     <span class="term"><i><tt class="parameter">link_identifier</tt></i></span>     <dd>      <p class="para">       The link identifier.      </p>     </dd>    </dt>    <dt>     <span class="term"><i><tt class="parameter">cursor_def</tt></i></span>     <dd>      <p class="para">       This optional parameter allows you to make this a        <i>scroll</i> and/or <i>hold</i> cursor.       It&#039;s a bitmask and can be either <b><tt>IFX_SCROLL</tt></b>,       <b><tt>IFX_HOLD</tt></b>, or both or&#039;ed together. I you omit this       parameter the cursor is a normal sequential cursor.      </p>     </dd>    </dt>    <dt>     <span class="term"><i><tt class="parameter">blobidarray</tt></i></span>     <dd>      <p class="para">       If you have BLOB (BYTE or TEXT) columns in the query, you can add       a <i><tt class="parameter">blobidarray</tt></i> parameter containing the       corresponding &quot;blob ids&quot;, and you should replace those columns       with a &quot;?&quot; in the query text.      </p>     </dd>    </dt>   </dl>  </p> </div> <div class="refsect1 returnvalues">  <h3 class="title">Return Values</h3>  <p class="para">   Returns valid Informix result identifier on success, or <b><tt>FALSE</tt></b> on errors.  </p> </div> <div class="refsect1 examples">  <h3 class="title">Examples</h3>  <p class="para">   <div class="example">    <p><b>Example #1      Show all rows of the &quot;orders&quot; table as a HTML table    </b></p>    <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />ifx_textasvarchar</span><span style="color: #007700">(</span><span style="color: #0000BB">1</span><span style="color: #007700">);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;use&nbsp;"text&nbsp;mode"&nbsp;for&nbsp;blobs<br /></span><span style="color: #0000BB">$res_id&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ifx_query</span><span style="color: #007700">(</span><span style="color: #DD0000">"select&nbsp;*&nbsp;from&nbsp;orders"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$conn_id</span><span style="color: #007700">);<br />if&nbsp;(!&nbsp;</span><span style="color: #0000BB">$res_id</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"Can't&nbsp;select&nbsp;orders&nbsp;:&nbsp;%s\n&lt;br&nbsp;/&gt;%s&lt;br&nbsp;/&gt;\n"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">ifx_error</span><span style="color: #007700">(),&nbsp;</span><span style="color: #0000BB">ifx_errormsg</span><span style="color: #007700">());<br />&nbsp;&nbsp;&nbsp;&nbsp;die;<br />}<br /></span><span style="color: #0000BB">ifx_htmltbl_result</span><span style="color: #007700">(</span><span style="color: #0000BB">$res_id</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"border=\"1\""</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">ifx_free_result</span><span style="color: #007700">(</span><span style="color: #0000BB">$res_id</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>    </div>   </div>   <div class="example">    <p><b>Example #2 Insert some values into the &quot;catalog&quot; table</b></p>    <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">//&nbsp;create&nbsp;blob&nbsp;id's&nbsp;for&nbsp;a&nbsp;byte&nbsp;and&nbsp;text&nbsp;column<br /></span><span style="color: #0000BB">$textid&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ifx_create_blob</span><span style="color: #007700">(</span><span style="color: #0000BB">0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"Text&nbsp;column&nbsp;in&nbsp;memory"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$byteid&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ifx_create_blob</span><span style="color: #007700">(</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"Byte&nbsp;column&nbsp;in&nbsp;memory"</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;store&nbsp;blob&nbsp;id's&nbsp;in&nbsp;a&nbsp;blobid&nbsp;array<br /></span><span style="color: #0000BB">$blobidarray</span><span style="color: #007700">[]&nbsp;=&nbsp;</span><span style="color: #0000BB">$textid</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$blobidarray</span><span style="color: #007700">[]&nbsp;=&nbsp;</span><span style="color: #0000BB">$byteid</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//&nbsp;launch&nbsp;query<br /></span><span style="color: #0000BB">$query&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"insert&nbsp;into&nbsp;catalog&nbsp;(stock_num,&nbsp;manu_code,&nbsp;"&nbsp;</span><span style="color: #007700">.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"cat_descr,cat_picture)&nbsp;values(1,'HRO',?,?)"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$res_id&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ifx_query</span><span style="color: #007700">(</span><span style="color: #0000BB">$query</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$conn_id</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$blobidarray</span><span style="color: #007700">);<br />if&nbsp;(!&nbsp;</span><span style="color: #0000BB">$res_id</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">/*&nbsp;...&nbsp;error&nbsp;...&nbsp;*/<br /></span><span style="color: #007700">}<br /><br /></span><span style="color: #FF8000">//&nbsp;free&nbsp;result&nbsp;id<br /></span><span style="color: #0000BB">ifx_free_result</span><span style="color: #007700">(</span><span style="color: #0000BB">$res_id</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>    </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.ifx-connect.html" class="function" rel="rdfs-seeAlso">ifx_connect()</a></li>   </ul>  </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.ifx-prepare.html">ifx_prepare</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.ifx-textasvarchar.html">ifx_textasvarchar</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 + -
显示快捷键?