Here is a way of testing that your transaction has started when using MySQL's InnoDB tables. It will fail if you are using MySQL's MyISAM tables, which do not support transactions but will also not return an error when using them.

<?// Begin the transaction$dbh->beginTransaction();

// To verify that a transaction has started, try to create an (illegal for InnoDB) nested transaction.// If it works, the first transaction did not start correctly or is unsupported (such as on MyISAM tables)try { $dbh->beginTransaction(); die('Cancelling, Transaction was not properly started');} catch (PDOException $e) { print "Transaction is running (because trying another one failed)\n";}?>

Should anyone reading this be slightly panicked because they just discovered that their MySQL tables are MyIsam and not InnoDb, don't worry... You can very easily change the storage engine using the following query: