Easy Tutorial
❮ Func Ftp Cdup Func Math Deg2Rad ❯

PHP mysqli_commit() Function

PHP MySQLi Reference Manual

Example

Turn off auto-commit, perform some queries, and then commit the queries:

<?php  
// Assume database username: root, password: 123456, database: tutorialpro  
$con = mysqli_connect("localhost", "root", "123456", "tutorialpro");  
if (mysqli_connect_errno($con))  
{  
    echo "Failed to connect to MySQL: " . mysqli_connect_error();  
}  

// Turn off auto-commit  
mysqli_autocommit($con, FALSE);  

// Insert some values  
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

The mysqli_commit() function commits the current transaction for the specified database connection.

Tip: See the mysqli_autocommit() function to enable or disable auto-commit of database modifications. See the mysqli_rollback() function to roll back the current transaction.


Syntax

Parameter Description
connection Required. Specifies the MySQL connection to use.

Technical Details

Return Value: Returns TRUE on success, FALSE on failure.
PHP Version: 5+
--- ---
❮ Func Ftp Cdup Func Math Deg2Rad ❯