PHP mysqli_commit () function
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);
?>
// 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_commit () function commits the current transaction specified database connection.
Tip: Check out mysqli_autocommit () function is used to enable or disable auto-commit database changes. See the mysqli_rollback () function is used to roll back the current transaction.
grammar
mysqli_commit( connection ) ;
参数 | 描述 |
---|---|
connection | 必需。规定要使用的 MySQL 连接。 |
technical details
return value: | If successful it returns TRUE, on failure returns FALSE. |
---|---|
PHP version: | 5+ |
PHP MySQLi Reference Manual