mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-18 13:57:03 +08:00
167 lines
10 KiB
HTML
167 lines
10 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>Send Informix query</title>
|
|
</head>
|
|
<body class="docs"><div id="layout">
|
|
<div id="layout-content"><div id="function.ifx-query" class="refentry">
|
|
<div class="refnamediv">
|
|
<h1 class="refname">ifx_query</h1>
|
|
<p class="verinfo">(PHP 4, PHP 5 < 5.2.1)</p><p class="refpurpose"><span class="refname">ifx_query</span> — <span class="dc-title">Send Informix query</span></p>
|
|
|
|
</div>
|
|
|
|
<div class="refsect1 description" id="refsect1-function.ifx-query-description">
|
|
<h3 class="title">说明</h3>
|
|
<div class="methodsynopsis dc-description">
|
|
<span class="methodname"><strong>ifx_query</strong></span>
|
|
( <span class="methodparam"><span class="type">string</span> <code class="parameter">$query</code></span>
|
|
, <span class="methodparam"><span class="type">resource</span> <code class="parameter">$link_identifier</code></span>
|
|
[, <span class="methodparam"><span class="type">int</span> <code class="parameter">$cursor_type</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">$blobidarray</code></span>
|
|
]] ) : <span class="type">resource</span></div>
|
|
|
|
<p class="para rdfs-comment">
|
|
Sends a <code class="parameter">query</code> to the currently active database on
|
|
the server that's associated with the specified link identifier.
|
|
</p>
|
|
<p class="para">
|
|
For "select-type" queries a cursor is declared and opened.
|
|
Non-select queries are "execute immediate".
|
|
</p>
|
|
<p class="para">
|
|
For either query type the number of (estimated or real) affected rows is
|
|
saved for retrieval by <span class="function"><a href="ifx_affected_rows.html" class="function">ifx_affected_rows()</a></span>.
|
|
</p>
|
|
<p class="para">
|
|
If the contents of the TEXT (or BYTE) column allow it, you can also use
|
|
<em>ifx_textasvarchar(1)</em> and
|
|
<em>ifx_byteasvarchar(1)</em>. 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't need to bother with blob id's.
|
|
</p>
|
|
<p class="para">
|
|
With <em>ifx_textasvarchar(0)</em> or
|
|
<em>ifx_byteasvarchar(0)</em> (the default situation), select
|
|
queries will return BLOB columns as blob id'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" id="refsect1-function.ifx-query-parameters">
|
|
<h3 class="title">参数</h3>
|
|
<p class="para">
|
|
<dl>
|
|
|
|
|
|
<dt>
|
|
<code class="parameter">query</code></dt>
|
|
|
|
<dd>
|
|
|
|
<p class="para">
|
|
The query string.
|
|
</p>
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>
|
|
<code class="parameter">link_identifier</code></dt>
|
|
|
|
<dd>
|
|
|
|
<p class="para">
|
|
The link identifier.
|
|
</p>
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>
|
|
<code class="parameter">cursor_def</code></dt>
|
|
|
|
<dd>
|
|
|
|
<p class="para">
|
|
This optional parameter allows you to make this a
|
|
<em>scroll</em> and/or <em>hold</em> cursor.
|
|
It's a bitmask and can be either <strong><code>IFX_SCROLL</code></strong>,
|
|
<strong><code>IFX_HOLD</code></strong>, or both or'ed together. I you omit this
|
|
parameter the cursor is a normal sequential cursor.
|
|
</p>
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>
|
|
<code class="parameter">blobidarray</code></dt>
|
|
|
|
<dd>
|
|
|
|
<p class="para">
|
|
If you have BLOB (BYTE or TEXT) columns in the query, you can add
|
|
a <code class="parameter">blobidarray</code> parameter containing the
|
|
corresponding "blob ids", and you should replace those columns
|
|
with a "?" in the query text.
|
|
</p>
|
|
</dd>
|
|
|
|
|
|
</dl>
|
|
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 returnvalues" id="refsect1-function.ifx-query-returnvalues">
|
|
<h3 class="title">返回值</h3>
|
|
<p class="para">
|
|
Returns valid Informix result identifier on success, or <strong><code>FALSE</code></strong> on errors.
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 examples" id="refsect1-function.ifx-query-examples">
|
|
<h3 class="title">范例</h3>
|
|
<p class="para">
|
|
<div class="example" id="example-1293">
|
|
<p><strong>Example #1
|
|
Show all rows of the "orders" table as a HTML table
|
|
</strong></p>
|
|
<div class="example-contents">
|
|
<div class="phpcode"><pre><span style="color: #000000">
|
|
<span style="color: #0000BB"><?php<br />ifx_textasvarchar</span><span style="color: #007700">(</span><span style="color: #0000BB">1</span><span style="color: #007700">); </span><span style="color: #FF8000">// use "text mode" for blobs<br /></span><span style="color: #0000BB">$res_id </span><span style="color: #007700">= </span><span style="color: #0000BB">ifx_query</span><span style="color: #007700">(</span><span style="color: #DD0000">"select * from orders"</span><span style="color: #007700">, </span><span style="color: #0000BB">$conn_id</span><span style="color: #007700">);<br />if (! </span><span style="color: #0000BB">$res_id</span><span style="color: #007700">) {<br /> </span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"Can't select orders : %s\n<br />%s<br />\n"</span><span style="color: #007700">, </span><span style="color: #0000BB">ifx_error</span><span style="color: #007700">(), </span><span style="color: #0000BB">ifx_errormsg</span><span style="color: #007700">());<br /> 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">, </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">?></span>
|
|
</span>
|
|
</pre></div>
|
|
</div>
|
|
|
|
</div>
|
|
<div class="example" id="example-1294">
|
|
<p><strong>Example #2 Insert some values into the "catalog" table</strong></p>
|
|
<div class="example-contents">
|
|
<div class="phpcode"><pre><span style="color: #000000">
|
|
<span style="color: #0000BB"><?php<br /><br /></span><span style="color: #FF8000">// create blob id's for a byte and text column<br /></span><span style="color: #0000BB">$textid </span><span style="color: #007700">= </span><span style="color: #0000BB">ifx_create_blob</span><span style="color: #007700">(</span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #DD0000">"Text column in memory"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$byteid </span><span style="color: #007700">= </span><span style="color: #0000BB">ifx_create_blob</span><span style="color: #007700">(</span><span style="color: #0000BB">1</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #DD0000">"Byte column in memory"</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// store blob id's in a blobid array<br /></span><span style="color: #0000BB">$blobidarray</span><span style="color: #007700">[] = </span><span style="color: #0000BB">$textid</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$blobidarray</span><span style="color: #007700">[] = </span><span style="color: #0000BB">$byteid</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">// launch query<br /></span><span style="color: #0000BB">$query </span><span style="color: #007700">= </span><span style="color: #DD0000">"insert into catalog (stock_num, manu_code, " </span><span style="color: #007700">.<br /> </span><span style="color: #DD0000">"cat_descr,cat_picture) values(1,'HRO',?,?)"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$res_id </span><span style="color: #007700">= </span><span style="color: #0000BB">ifx_query</span><span style="color: #007700">(</span><span style="color: #0000BB">$query</span><span style="color: #007700">, </span><span style="color: #0000BB">$conn_id</span><span style="color: #007700">, </span><span style="color: #0000BB">$blobidarray</span><span style="color: #007700">);<br />if (! </span><span style="color: #0000BB">$res_id</span><span style="color: #007700">) {<br /> </span><span style="color: #FF8000">/* ... error ... */<br /></span><span style="color: #007700">}<br /><br /></span><span style="color: #FF8000">// free result 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">?></span>
|
|
</span>
|
|
</pre></div>
|
|
</div>
|
|
|
|
</div>
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 seealso" id="refsect1-function.ifx-query-seealso">
|
|
<h3 class="title">参见</h3>
|
|
<p class="para">
|
|
<ul class="simplelist">
|
|
<li class="member"><span class="function"><a href="ifx_connect.html" class="function" rel="rdfs-seeAlso">ifx_connect()</a> - Open Informix server connection</span></li>
|
|
</ul>
|
|
</p>
|
|
</div>
|
|
|
|
|
|
</div></div></div></body></html> |