//connect to the database $conn = new mysqli('localhost', 'username', 'password', 'database'); //start a transaction $conn->begin_transaction(); try { //insert data into a table $conn->query("INSERT INTO mytable (col1, col2, col3) VALUES ('value1', 'value2', 'value3')"); //perform some other actions or queries //commit the transaction $conn->commit(); } catch (\Exception $e) { //if an error occurred, rollback the transaction $conn->rollback(); echo "Error: " . $e->getMessage(); }In this example, we start a transaction using mysqli's begin_transaction method, then perform some actions or queries within the transaction. If an error occurs, we catch the exception and rollback the transaction using mysqli's rollback method. If everything is successful, we commit the transaction using mysqli's commit method. Package library: The mysqli rollback method is part of the PHP mysqli extension, which is a library provided by PHP that allows us to interact with a MySQL database.