mysqli_autocommit
(PHP 5 CVS only)
mysqli_autocommit -- Turns on or off auto-committing database modifications
Description
bool
mysqli_autocommit ( object link, bool mode)
mysqli_autocommit() is used to turn on or off auto-commit mode
on queries for the database connection represented by the link
resource.
Returns TRUE on success or FALSE on failure.
Note:
mysqli_autocommit() doesn't work with non transactional
table types (like MyISAM or ISAM).
To determine the current state of autocommit use the SQL command
'SELECT @@autocommit'.
Example 1. Using the mysqli_autocommit function Procedural style:
<?php
/* Open a connection */ $link = mysqli_connect("localhost", "user", "pass", "mydb"); /* Turn on autocommit */ mysqli_autocommit($link, true);
/* determine current autocommit status */ if ($result = mysqli_query($link, "SELECT @@autocommit")) { $row = mysqli_fetch_row($result); mysqli_free_result($result); printf("Autocommit is %d\n", $row[0]); }
/* close connection */ mysqli_close($link); ?>
|
Object oriented style:
<?php
/* Open a connection */ $mysql = mysqli_connect("localhost", "user", "pass", "mydb"); /* Turn on autocommit */ $mysql->autocommit(true);
/* determine current autocommit status */ if ($result = $mysql->query($link, "SELECT @@autocommit")) { $row = $result->fetch_row($result); printf ("Autocommit is %d\n", $row[0]); $result->free(); }
/* close connection */ $mysql->close(); ?>
|
The above examples would produce the following output:
|
See also mysqli_commit(),
mysqli_rollback().