$database->beginTransaction();
// ...
try {
// ...
$database->commitTransaction();
} catch(\Exception $e) {
$database->rollbackTransaction();
throw $e;
}
Each transaction is stored in the binary log in one chunk, upon COMMIT. Transactions that are rolled back are not logged.
Rolling back can be a slow operation that may occur implicitly without the user having explicitly asked for it (for example, when an error occurs).
Beginning a transaction also causes table locks acquired with LOCK TABLES to be released
Обьясните, пожалуйста, зачем тут нужен откат транзакции, если все изменения фиксируются при коммите, а исключение и так прервет программу?