Transactions allow us to execute a group of SQL commands as a single, atomic unit. If any command fails, we can undo
all changes and return the database to its state before the start. In PDO, we manage transactions with three key methods:
beginTransaction() (start), commit() (confirm all changes), and rollBack()
(cancel everything in case of an error).
In the example above, we attempted to insert two new records into the users table simultaneously. If an
error occurred during the second insertion, PDO would use the catch block to discard the first entry as
well, keeping the database clean and consistent.
beginTransaction() disables autocommit mode.commit() permanently saves all changes made within the transaction.rollBack() is triggered in the catch block and reverts all commands since the start
of the transaction.