Example 1 — Turn Autocommit Off
Disable autocommit before a short group of writes. Sample output when connected to a demo database.
<?php
$mysqli = mysqli_connect("localhost", "demo", "secret", "shop");
if (mysqli_autocommit($mysqli, false)) {
echo "Autocommit is off.", PHP_EOL;
}
mysqli_close($mysqli); How It Works
- Connect with placeholder demo credentials.
- mysqli_autocommit($mysqli, false) disables automatic commit.
- The function returns true when the setting is accepted.
- Later you would commit or roll back, then close the connection.

