uTools-Manuals/docs/php/odbc_setoption.html
2019-04-08 23:22:26 +08:00

136 lines
6.1 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!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>Adjust ODBC settings</title>
</head>
<body class="docs"><div id="layout">
<div id="layout-content"><div id="function.odbc-setoption" class="refentry">
<div class="refnamediv">
<h1 class="refname">odbc_setoption</h1>
<p class="verinfo">(PHP 4, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">odbc_setoption</span> &mdash; <span class="dc-title">Adjust ODBC settings</span></p>
</div>
<div class="refsect1 description" id="refsect1-function.odbc-setoption-description">
<h3 class="title">说明</h3>
<div class="methodsynopsis dc-description">
<span class="methodname"><strong>odbc_setoption</strong></span>
( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$id</code></span>
, <span class="methodparam"><span class="type">int</span> <code class="parameter">$function</code></span>
, <span class="methodparam"><span class="type">int</span> <code class="parameter">$option</code></span>
, <span class="methodparam"><span class="type">int</span> <code class="parameter">$param</code></span>
) : <span class="type">bool</span></div>
<p class="para rdfs-comment">
This function allows fiddling with the ODBC options for a
particular connection or query result. It was written to help
find work around to problems in quirky ODBC drivers. You should
probably only use this function if you are an ODBC programmer and
understand the effects the various options will have. You will
certainly need a good ODBC reference to explain all the different
options and values that can be used. Different driver versions
support different options.
</p>
<p class="para">
Because the effects may vary depending on the ODBC driver, use of
this function in scripts to be made publicly available is
strongly discouraged. Also, some ODBC options are not available
to this function because they must be set before the connection
is established or the query is prepared. However, if on a
particular job it can make PHP work so your boss doesn&#039;t tell you
to use a commercial product, that&#039;s all that really
matters.
</p>
</div>
<div class="refsect1 parameters" id="refsect1-function.odbc-setoption-parameters">
<h3 class="title">参数</h3>
<p class="para">
<dl>
<dt>
<code class="parameter">id</code></dt>
<dd>
<p class="para">
Is a connection id or result id on which to change the settings.
For SQLSetConnectOption(), this is a connection id.
For SQLSetStmtOption(), this is a result id.
</p>
</dd>
<dt>
<code class="parameter">function</code></dt>
<dd>
<p class="para">
Is the ODBC function to use. The value should be
1 for SQLSetConnectOption() and
2 for SQLSetStmtOption().
</p>
</dd>
<dt>
<code class="parameter">option</code></dt>
<dd>
<p class="para">
The option to set.
</p>
</dd>
<dt>
<code class="parameter">param</code></dt>
<dd>
<p class="para">
The value for the given <code class="parameter">option</code>.
</p>
</dd>
</dl>
</p>
</div>
<div class="refsect1 returnvalues" id="refsect1-function.odbc-setoption-returnvalues">
<h3 class="title">返回值</h3>
<p class="para">
成功时返回 <strong><code>TRUE</code></strong> 或者在失败时返回 <strong><code>FALSE</code></strong>
</p>
</div>
<div class="refsect1 examples" id="refsect1-function.odbc-setoption-examples">
<h3 class="title">范例</h3>
<p class="para">
<div class="example" id="example-986">
<p><strong>Example #1 <span class="function"><strong>odbc_setoption()</strong></span> examples</strong></p>
<div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">//&nbsp;1.&nbsp;Option&nbsp;102&nbsp;of&nbsp;SQLSetConnectOption()&nbsp;is&nbsp;SQL_AUTOCOMMIT.<br />//&nbsp;&nbsp;&nbsp;&nbsp;Value&nbsp;1&nbsp;of&nbsp;SQL_AUTOCOMMIT&nbsp;is&nbsp;SQL_AUTOCOMMIT_ON.<br />//&nbsp;&nbsp;&nbsp;&nbsp;This&nbsp;example&nbsp;has&nbsp;the&nbsp;same&nbsp;effect&nbsp;as<br />//&nbsp;&nbsp;&nbsp;&nbsp;odbc_autocommit($conn,&nbsp;true);<br /><br /></span><span style="color: #0000BB">odbc_setoption</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">102</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;2.&nbsp;Option&nbsp;0&nbsp;of&nbsp;SQLSetStmtOption()&nbsp;is&nbsp;SQL_QUERY_TIMEOUT.<br />//&nbsp;&nbsp;&nbsp;&nbsp;This&nbsp;example&nbsp;sets&nbsp;the&nbsp;query&nbsp;to&nbsp;timeout&nbsp;after&nbsp;30&nbsp;seconds.<br /><br /></span><span style="color: #0000BB">$result&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">odbc_prepare</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$sql</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">odbc_setoption</span><span style="color: #007700">(</span><span style="color: #0000BB">$result</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">2</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">30</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">odbc_execute</span><span style="color: #007700">(</span><span style="color: #0000BB">$result</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
</div>
</div>
</p>
</div>
</div></div></div></body></html>