Reputation: 5792
I want to achieve accurate accounting in php and mysql. My code is working 100% fine.
For Debit:
$query = new QUERY(array('TABLE'=>'account_treasury_local_agent'));
$query->save($data);
And for Credit:
$query = new QUERY(array('TABLE'=>'account_treasury_headquarters'));
$query->save($data2);
The problem is, I want to revert whole transaction if there is an error in second function. I mean, I want to run this two queries together. Without debit, credit shouldn't be possible and vice versa.
EDIT:
I know, it's possible by means of TRANSACTION START, COMMIT, ROLLBACK. But, I have no idea, how to implement it with php.
Thanks.
Upvotes: 1
Views: 943
Reputation: 37803
To begin the transaction: BEGIN
(or START TRANSACTION
).
To commit: COMMIT
.
To roll back: ROLLBACK
.
That's all there is to it.
Upvotes: 1