Latest web development tutorials

PHP mysqli_autocommit () function

PHP MySQLi Reference Manual PHP MySQLi Reference Manual

Examples

Turn off auto-commit, do some queries, then submit the query:

<? php
// Assumes that the database username: root, password: 123456, database: w3big
$ con = mysqli_connect ( "localhost" , "root", "123456", "w3big");
if (mysqli_connect_errno ($ con))
{
echo "MySQL connection failed:" mysqli_connect_error ();.
}

// Close Autocommit
mysqli_autocommit ($ con, FALSE);

// Insert some value
mysqli_query ($ con, "INSERT INTO websites (name, url, alexa, country)
VALUES ( 'Baidu', 'https: //www.baidu.com/','4','CN') ");

// Commit the transaction
mysqli_commit ($ con);

// Close the connection
mysqli_close ($ con);
?>

Definition and Usage

mysqli_autocommit () function to enable or disable auto-commit database changes.

Tip: Check out mysqli_commit () function is used to commit the current transaction specified database connection. See the mysqli_rollback () function is used to roll back the current transaction.


grammar

mysqli_autocommit( connection,mode ) ;

参数 描述
connection 必需。规定要使用的 MySQL 连接。
mode 必需。如果设置为 FALSE,则表示关闭 auto-commit。如果设置为 TRUE,则表示开启 auto-commit(提交任何等待查询)。

technical details

return value: If successful it returns TRUE, on failure returns FALSE.
PHP version: 5+


PHP MySQLi Reference Manual PHP MySQLi Reference Manual