php-doc-en/reference/mysqli/functions/mysqli-autocommit.xml
Nuno Lopes a5146131c6 reverting
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@153795 c90b9560-bf6c-de11-be94-00142212c4b1
2004-03-16 15:36:17 +00:00

141 lines
3.5 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.15 $ -->
<refentry id="function.mysqli-autocommit">
<refnamediv>
<refname>mysqli_autocommit</refname>
<refname> mysqli->auto_commit</refname>
<refpurpose>Turns on or off auto-commiting database modifications</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<para>Procedural style:</para>
<methodsynopsis>
<type>bool</type><methodname>mysqli_autocommit</methodname>
<methodparam><type>object</type><parameter>link</parameter></methodparam>
<methodparam><type>bool</type><parameter>mode</parameter></methodparam>
</methodsynopsis>
<para>Object oriented style (method)</para>
<classsynopsis>
<ooclass><classname>mysqli</classname></ooclass>
<methodsynopsis>
<type>bool</type>
<methodname>auto_commit</methodname>
<methodparam><type>bool</type><parameter>mode</parameter></methodparam>
</methodsynopsis>
</classsynopsis>
<para>
<function>mysqli_autocommit</function> is used to turn on or off auto-commit mode
on queries for the database connection represented by the <parameter>link</parameter>
object.
</para>
<note>
<para>
<function>mysqli_autocommit</function> doesn't work with non transactional
table types (like MyISAM or ISAM).
</para>
<para>
To determine the current state of autocommit use the SQL command
'SELECT @@autocommit'.
</para>
</note>
</refsect1>
<refsect1>
<title>Return values</title>
<para>
&return.success;
</para>
</refsect1>
<refsect1>
<title>See also</title>
<para>
<function>mysqli_commit</function>,
<function>mysqli_rollback</function>.
</para>
</refsect1>
<refsect1>
<title>Example</title>
<example>
<title>Object oriented style</title>
<programlisting role="php">
<![CDATA[
<?php
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
/* turn autocommit on */
$mysqli->autocommit(TRUE);
if ($result = $mysqli->query("SELECT @@autocommit")) {
$row = $result->fetch_row();
printf("Autocommit is %s\n", $row[0]);
$result->free();
}
/* close connection */
$mysqli->close();
?>
]]>
</programlisting>
</example>
<example>
<title>Procedural style</title>
<programlisting role="php">
<![CDATA[
<?php
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
if (!$link) {
printf("Can't connect to localhost. Error: %s\n", mysqli_connect_error());
exit();
}
/* turn autocommit on */
mysqli_autocommit($link, TRUE);
if ($result = mysqli_query($link, "SELECT @@autocommit")) {
$row = mysqli_fetch_row($result);
printf("Autocommit is %s\n", $row[0]);
mysqli_free_result($result);
}
/* close connection */
mysqli_close($link);
?>
]]>
</programlisting>
</example>
<para>
The above examples would produce the following output:
</para>
<screen>
<![CDATA[
Autocommit is 1
]]>
</screen>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->