I\'m pretty new to transactions.
Before, what I was doing was something like:
Code Block 1
$db = new PDO(...);
$stmt = $db->prepare(
The execution is stopped when an exception is thrown.
The first return will not be reached but the catch statement will be executed.
You can even return the commit directly:
$dbh->beginTransaction();
try {
// insert/update query
return $dbh->commit();
} catch (PDOException $e) {
$dbh->rollBack();
return false;
}