The following example begins a transaction and issues two statements
that modify the database before rolling back the changes. On MySQL,
however, the DROP TABLE statement automatically commits the
transaction so that none of the changes in the transaction are rolled
back.
<?php
/* Begin a transaction, turning off autocommit */
$dbh->beginTransaction();
/* Change the database schema and data */
$sth = $dbh->exec("DROP TABLE fruit");
$sth = $dbh->exec("UPDATE dessert
SET name = 'hamburger'");
/* Recognize mistake and roll back changes */
$dbh->rollBack();
/* Database connection is now back in autocommit mode */
?>