mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-18 13:57:03 +08:00
136 lines
6.1 KiB
HTML
136 lines
6.1 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>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> — <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't tell you
|
||
to use a commercial product, that'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"><?php<br /></span><span style="color: #FF8000">// 1. Option 102 of SQLSetConnectOption() is SQL_AUTOCOMMIT.<br />// Value 1 of SQL_AUTOCOMMIT is SQL_AUTOCOMMIT_ON.<br />// This example has the same effect as<br />// odbc_autocommit($conn, 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">, </span><span style="color: #0000BB">1</span><span style="color: #007700">, </span><span style="color: #0000BB">102</span><span style="color: #007700">, </span><span style="color: #0000BB">1</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// 2. Option 0 of SQLSetStmtOption() is SQL_QUERY_TIMEOUT.<br />// This example sets the query to timeout after 30 seconds.<br /><br /></span><span style="color: #0000BB">$result </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: #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">, </span><span style="color: #0000BB">2</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </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">?></span>
|
||
</span>
|
||
</pre></div>
|
||
</div>
|
||
|
||
</div>
|
||
</p>
|
||
</div>
|
||
|
||
|
||
</div></div></div></body></html> |