The inTransaction() method checks if a transaction is currently active on the database connection.
This means it verifies if we have previously called beginTransaction() and have not yet closed the
transaction with commit or rollback. This method is extremely useful in more complex
systems where we want to prevent errors that occur when trying to open a new transaction while one is already open.
Practical Application: We use this method before starting a new operation to make sure of the connection state and prevent overlapping transactions. Check the process at home by following these steps:
true if a transaction is active, and false if
it is not.pdo_db database so that the connection in the example works
correctly.