mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-18 13:57:03 +08:00
116 lines
5.4 KiB
HTML
116 lines
5.4 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>Prepares a statement for execution</title>
|
|
</head>
|
|
<body class="docs"><div id="layout">
|
|
<div id="layout-content"><div id="function.odbc-prepare" class="refentry">
|
|
<div class="refnamediv">
|
|
<h1 class="refname">odbc_prepare</h1>
|
|
<p class="verinfo">(PHP 4, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">odbc_prepare</span> — <span class="dc-title">Prepares a statement for execution</span></p>
|
|
|
|
</div>
|
|
|
|
<div class="refsect1 description" id="refsect1-function.odbc-prepare-description">
|
|
<h3 class="title">说明</h3>
|
|
<div class="methodsynopsis dc-description">
|
|
<span class="methodname"><strong>odbc_prepare</strong></span>
|
|
( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$connection_id</code></span>
|
|
, <span class="methodparam"><span class="type">string</span> <code class="parameter">$query_string</code></span>
|
|
) : <span class="type">resource</span></div>
|
|
|
|
<p class="para rdfs-comment">
|
|
Prepares a statement for execution. The result identifier can be used
|
|
later to execute the statement with <span class="function"><a href="odbc_execute.html" class="function">odbc_execute()</a></span>.
|
|
</p>
|
|
<p class="para">
|
|
Some databases (such as IBM DB2, MS SQL Server, and Oracle) support
|
|
stored procedures that accept parameters of type IN, INOUT, and OUT as
|
|
defined by the ODBC specification. However, the Unified ODBC driver
|
|
currently only supports parameters of type IN to stored procedures.
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 parameters" id="refsect1-function.odbc-prepare-parameters">
|
|
<h3 class="title">参数</h3>
|
|
<p class="para">
|
|
<dl>
|
|
|
|
|
|
<dt>
|
|
<code class="parameter">connection_id</code></dt>
|
|
|
|
<dd>
|
|
|
|
<p class="para">ODBC 连接标识符,详见
|
|
<span class="function"><a href="odbc_connect.html" class="function">odbc_connect()</a></span>。</p>
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>
|
|
<code class="parameter">query_string</code></dt>
|
|
|
|
<dd>
|
|
|
|
<p class="para">
|
|
The query string statement being prepared.
|
|
</p>
|
|
</dd>
|
|
|
|
|
|
</dl>
|
|
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 returnvalues" id="refsect1-function.odbc-prepare-returnvalues">
|
|
<h3 class="title">返回值</h3>
|
|
<p class="para">
|
|
Returns an ODBC result identifier if the SQL command was prepared
|
|
successfully. Returns <strong><code>FALSE</code></strong> on error.
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 examples" id="refsect1-function.odbc-prepare-examples">
|
|
<h3 class="title">范例</h3>
|
|
<p class="para">
|
|
<div class="example" id="example-984">
|
|
<p><strong>Example #1 <span class="function"><a href="odbc_execute.html" class="function">odbc_execute()</a></span> and <span class="function"><strong>odbc_prepare()</strong></span> example</strong></p>
|
|
<div class="example-contents"><p>
|
|
In the following code, <var class="varname"><var class="varname">$success</var></var> will only be
|
|
<strong><code>TRUE</code></strong> if all three parameters to myproc are IN parameters:
|
|
</p></div>
|
|
<div class="example-contents">
|
|
<div class="phpcode"><pre><span style="color: #000000">
|
|
<span style="color: #0000BB"><?php<br />$a </span><span style="color: #007700">= </span><span style="color: #0000BB">1</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$b </span><span style="color: #007700">= </span><span style="color: #0000BB">2</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$c </span><span style="color: #007700">= </span><span style="color: #0000BB">3</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$stmt </span><span style="color: #007700">= </span><span style="color: #0000BB">odbc_prepare</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">, </span><span style="color: #DD0000">'CALL myproc(?,?,?)'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$success </span><span style="color: #007700">= </span><span style="color: #0000BB">odbc_execute</span><span style="color: #007700">(</span><span style="color: #0000BB">$stmt</span><span style="color: #007700">, array(</span><span style="color: #0000BB">$a</span><span style="color: #007700">, </span><span style="color: #0000BB">$b</span><span style="color: #007700">, </span><span style="color: #0000BB">$c</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?></span>
|
|
</span>
|
|
</pre></div>
|
|
</div>
|
|
|
|
</div>
|
|
</p>
|
|
<p class="para">
|
|
If you need to call a stored procedure using INOUT or OUT parameters,
|
|
the recommended workaround is to use a native extension for your database
|
|
(for example, <a href="ref.mssql.html" class="link">mssql</a> for MS SQL Server,
|
|
or <a href="ref.mssql.html" class="link">oci8</a> for Oracle).
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 seealso" id="refsect1-function.odbc-prepare-seealso">
|
|
<h3 class="title">参见</h3>
|
|
<p class="para">
|
|
<ul class="simplelist">
|
|
<li class="member"><span class="function"><a href="odbc_execute.html" class="function" rel="rdfs-seeAlso">odbc_execute()</a> - Execute a prepared statement</span></li>
|
|
</ul>
|
|
</p>
|
|
</div>
|
|
|
|
|
|
</div></div></div></body></html> |