PDO API also standardises the transaction handling methods. By default, after the successful creation of the PDO connection, it is set to autocommit
mode. This means that for every database that supports transactions, every query is wrapped in an implicit transaction. For those database that do not support transactions, every query is executed as is.
Typically, the transaction handling strategy is this:
Of course, only the code that updates the database and the code that can break data integrity should be handled in a transaction. A classic example of a transaction is a money transfer:
1. Begin the transaction.
2. If there is enough money on the payer's account:
Subtract the amount from the payer's account.
Add the amount to the beneficiary...