<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.21 $ -->
<refentry xml:id="function.mysqli-autocommit" xmlns="http://docbook.org/ns/docbook">
 <refnamediv>
  <refname>mysqli_autocommit</refname>
  <refname>mysqli->autocommit()</refname>
  <refpurpose>Turns on or off auto-commiting database modifications</refpurpose>
 </refnamediv>

 <refsect1 role="description">
  &reftitle.description;
  <para>Procedural style:</para>
  <methodsynopsis>
   <type>bool</type><methodname>mysqli_autocommit</methodname>
   <methodparam><type>mysqli</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>autocommit</methodname>
    <methodparam><type>bool</type><parameter>mode</parameter></methodparam>
   </methodsynopsis>
  </classsynopsis>
  <para>
   Turns on or off auto-commit mode on queries for the database connection.
  </para>
  <para>
   To determine the current state of autocommit use the SQL command
   <literal>SELECT @@autocommit</literal>.
  </para>
 </refsect1>

 <refsect1 role="parameters">
  &reftitle.parameters;
  <para>
   <variablelist>
    &mysqli.link.description;
    <varlistentry>
     <term><parameter>mode</parameter></term>
     <listitem>
      <para>
       Whether to turn on auto-commit or not.
      </para>
     </listitem>
    </varlistentry>
   </variablelist>
  </para>
 </refsect1>

 <refsect1 role="returnvalues">
  &reftitle.returnvalues;
  <para>
   &return.success;
  </para>
 </refsect1>

 <refsect1 role="notes">
  &reftitle.notes;
  <note>
   <para>
    This function doesn't work with non transactional table types (like
    MyISAM or ISAM).
   </para>
  </note>
 </refsect1>

 <refsect1 role="examples">
  &reftitle.examples;
  <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>
  &example.outputs;
  <screen>
<![CDATA[
Autocommit is 1
]]>
  </screen>
 </refsect1>

 <refsect1 role="seealso">
  &reftitle.seealso;
  <para>
   <simplelist>
    <member><function>mysqli_commit</function></member>
    <member><function>mysqli_rollback</function></member>
   </simplelist>
  </para>
 </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
-->