Sometimes we need to use the database transaction
for saving the data in the tables for a complex application. Like booking
online tickets for any show, movies, bus and planes.
In this case there will be some probability that the
data will not be saved in the database due to a reason, like network failure,
database inconsistency or table integrity etc.
There might be a case where data is saved partially
in some tables and will create data inconsistency. The best example we can take
here is ATM. i.e. you got a message that the amount has deducted from your
account but you did not receive the money from the ATM.
To handle situations like this the CakePHP 2.x
provides a feature transaction. Using transactions we cannot avoid the
situation but can protect the harm it causes.
To perform a transaction, a model’s table must be of
a data source and type which supports transactions.
All transaction methods must be performed on a
model’s Data Source object. To get a model’s Data Source from within the model use:
Read More on Transaction In Database Operation In CakePHP
No comments:
Post a Comment