Phalcon Model Transactions

A model transaction helps to maintain the integrity of the database after the operations such as insert/delete/update/rollback etc. Transaction checks whether the operations are successfully completed or not before committing the database.

Transactions are of 3 types:

  1. Manual Transactions
  2. Implicit Transactions
  3. Isolated Transactions

Manual Transactions

This method is used when there is only one connection and easy transaction. This transaction can be created by just moving the current connection into transaction mode and then commit or rollback the operation whether it is successful or not.

Implementation

Output:

Phalcon Model Transaction 1

Implicit Transactions

Implicit transaction ensures that the data is stored correctly.

Implementation


Isolated Transactions

Isolated transactions are executed in a new connection ensuring that all the generated SQL, virtual foreign key checks and business rules are isolated from the main connection.

Implementation


Next TopicPhalcon Cookies




Latest Courses