📄 function.db2-autocommit.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Returns or sets the AUTOCOMMIT state for a database connection</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="ref.ibm-db2.html">IBM DB2 Functions</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.db2-bind-param.html">db2_bind_param</a></div> <div class="up"><a href="ref.ibm-db2.html">IBM DB2 Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.db2-autocommit" class="refentry"> <div class="refnamediv"> <h1 class="refname">db2_autocommit</h1> <p class="verinfo">(PECL ibm_db2:1.0-1.6.2)</p><p class="refpurpose"><span class="refname">db2_autocommit</span> — <span class="dc-title"> Returns or sets the AUTOCOMMIT state for a database connection </span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <span class="methodname"><b><b>db2_autocommit</b></b></span> ( <span class="methodparam"><span class="type">resource</span> <tt class="parameter">$connection</tt></span> [, <span class="methodparam"><span class="type">bool</span> <tt class="parameter">$value</tt></span> ] )</div> <p class="para rdfs-comment"> Sets or gets the AUTOCOMMIT behavior of the specified connection resource. </p> </div> <div class="refsect1 parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><i><tt class="parameter">connection</tt></i></span> <dd> <p class="para"> A valid database connection resource variable as returned from <a href="function.db2-connect.html" class="function">db2_connect()</a> or <a href="function.db2-pconnect.html" class="function">db2_pconnect()</a>. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">value</tt></i></span> <dd> <p class="para"> One of the following constants: <dl> <dt> <br /><span class="term"><i>DB2_AUTOCOMMIT_OFF</i></span> <dd> <p class="para"> Turns AUTOCOMMIT off. </p> </dd> </dt> <dt> <span class="term"><i>DB2_AUTOCOMMIT_ON</i></span> <dd> <p class="para"> Turns AUTOCOMMIT on. </p> </dd> </dt> </dl> </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> When <b>db2_autocommit()</b> receives only the <i><tt class="parameter">connection</tt></i> parameter, it returns the current state of AUTOCOMMIT for the requested connection as an integer value. A value of 0 indicates that AUTOCOMMIT is off, while a value of 1 indicates that AUTOCOMMIT is on. </p> <p class="para"> When <b>db2_autocommit()</b> receives both the <i><tt class="parameter">connection</tt></i> parameter and <i><tt class="parameter">autocommit</tt></i> parameter, it attempts to set the AUTOCOMMIT state of the requested connection to the corresponding state. Returns <b><tt>TRUE</tt></b> on success or <b><tt>FALSE</tt></b> on failure. </p> </div> <div class="refsect1 examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example"> <p><b>Example #1 Retrieving the AUTOCOMMIT value for a connection</b></p> <div class="example-contents"><p> In the following example, a connection which has been created with AUTOCOMMIT turned off is tested with the <b>db2_autocommit()</b> function. </p></div> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br />$options </span><span style="color: #007700">= array(</span><span style="color: #DD0000">'autocommit' </span><span style="color: #007700">=> </span><span style="color: #0000BB">DB2_AUTOCOMMIT_OFF</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$conn </span><span style="color: #007700">= </span><span style="color: #0000BB">db2_connect</span><span style="color: #007700">(</span><span style="color: #0000BB">$database</span><span style="color: #007700">, </span><span style="color: #0000BB">$user</span><span style="color: #007700">, </span><span style="color: #0000BB">$password</span><span style="color: #007700">, </span><span style="color: #0000BB">$options</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$ac </span><span style="color: #007700">= </span><span style="color: #0000BB">db2_autocommit</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">);<br />if (</span><span style="color: #0000BB">$ac </span><span style="color: #007700">== </span><span style="color: #0000BB">0</span><span style="color: #007700">) {<br /> print </span><span style="color: #DD0000">"$ac -- AUTOCOMMIT is off."</span><span style="color: #007700">;<br />} else {<br /> print </span><span style="color: #DD0000">"$ac -- AUTOCOMMIT is on."</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?></span></span></code></div> </div> <div class="example-contents"><p>The above example will output:</p></div> <div class="example-contents"><pre><div class="cdata"><pre>0 -- AUTOCOMMIT is off.</pre></div> </pre></div> </div> <div class="example"> <p><b>Example #2 Setting the AUTOCOMMIT value for a connection</b></p> <div class="example-contents"><p> In the following example, a connection which was initially created with AUTOCOMMIT turned off has its behavior changed to turn AUTOCOMMIT on. </p></div> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br />$options </span><span style="color: #007700">= array(</span><span style="color: #DD0000">'autocommit' </span><span style="color: #007700">=> </span><span style="color: #0000BB">DB2_AUTOCOMMIT_OFF</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$conn </span><span style="color: #007700">= </span><span style="color: #0000BB">db2_connect</span><span style="color: #007700">(</span><span style="color: #0000BB">$database</span><span style="color: #007700">, </span><span style="color: #0000BB">$user</span><span style="color: #007700">, </span><span style="color: #0000BB">$password</span><span style="color: #007700">, </span><span style="color: #0000BB">$options</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Turn AUTOCOMMIT on<br /></span><span style="color: #0000BB">$rc </span><span style="color: #007700">= </span><span style="color: #0000BB">db2_autocommit</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">, </span><span style="color: #0000BB">DB2_AUTOCOMMIT_ON</span><span style="color: #007700">);<br />if (</span><span style="color: #0000BB">$rc</span><span style="color: #007700">) {<br /> print </span><span style="color: #DD0000">"Turning AUTOCOMMIT on succeeded.\n"</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #FF8000">// Check AUTOCOMMIT state<br /></span><span style="color: #0000BB">$ac </span><span style="color: #007700">= </span><span style="color: #0000BB">db2_autocommit</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">);<br />if (</span><span style="color: #0000BB">$ac </span><span style="color: #007700">== </span><span style="color: #0000BB">0</span><span style="color: #007700">) {<br /> print </span><span style="color: #DD0000">"$ac -- AUTOCOMMIT is off."</span><span style="color: #007700">;<br />} else {<br /> print </span><span style="color: #DD0000">"$ac -- AUTOCOMMIT is on."</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?></span></span></code></div> </div> <div class="example-contents"><p>The above example will output:</p></div> <div class="example-contents"><pre><div class="cdata"><pre>Turning AUTOCOMMIT on succeeded.1 -- AUTOCOMMIT is on.</pre></div> </pre></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.db2-connect.html" class="function" rel="rdfs-seeAlso">db2_connect()</a></li> <li class="member"><a href="function.db2-pconnect.html" class="function" rel="rdfs-seeAlso">db2_pconnect()</a></li> </ul> </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="ref.ibm-db2.html">IBM DB2 Functions</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.db2-bind-param.html">db2_bind_param</a></div> <div class="up"><a href="ref.ibm-db2.html">IBM DB2 Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -