Triger after update as a solution to debit credit securely

0

I need to make an interface that guarantees the integrity of the customer's credit. In PHP, when we use LOCK explicitly in the PDO, with LOCK TABLES, if there is an inconsistency, when the same client object is in several processes relating even indirectly to the act of debiting credits. On the other hand, implicit LOCK, using a TRIGGER, can be more secure. Let the bank do the service. It is possible in a After After trigger, after updating the credits of the table credits, make an operation to check if the credits are negative, and in the vessel to be, then do a rolback of the transaction. If it is possible, what is the best way to do it. I thought about doing the operation inside a block try catch and catch the exception. Someone help me with this analogy, Thanks

    
asked by anonymous 21.02.2017 / 20:18

0 answers