Here's an example of using transactions in PDO.
NOTE: Calling beginTransaction() turns off auto commit automatically.
<?php try { $db->beginTransaction(); $db->exec("SOME QUERY"); $stmt = $db->prepare("SOME OTHER QUERY?"); $stmt->execute(array($value)); $stmt = $db->prepare("YET ANOTHER QUERY??"); $stmt->execute(array($value2, $value3)); $db->commit(); } catch(PDOException $ex) { // Something went wrong rollback! $db->rollBack(); echo $ex->getMessage(); }