Turn off autocommit, do some queries, and then submit the query:
<?php // Assume database username: root, password: 123456, database: CODERCTO $con = mysqli_connect ( "localhost" , "root" , "123456" , "CODERCTO" ); if ( mysqli_connect_errno ( $con )) { echo "Failed to connect to MySQL: " . mysqli_connect_error (); } // Turn off automatic submission 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 transaction mysqli_commit ( $con ); // Close connection mysqli_close ( $con ); ?>The mysqli_autocommit() function turns on or off automatic submission of database modifications.
Tip: See the mysqli_commit() function, which commits the current transaction for a specified database connection. Please see the mysqli_rollback() function for rolling back the current transaction.
mysqli_autocommit( connection,mode ) ;
parameter | describe |
---|---|
connection | Required. Specifies the MySQL connection to use. |
mode | Required. If set to FALSE, auto-commit is turned off. If set to TRUE, auto-commit is turned on (submitting any pending queries). |
Return value: | Returns TRUE if successful and FALSE if failed. |
---|---|
PHP version: | 5+ |