I was wondering as to
how do I ensure multiple queries are executed
or rollback to original state if one of the query fail
For example:
$qry1 = insert into table 1 (coloum1,coloum2) values(a,b);
$qry2 = update table 2 set coloum3 = coloum3 - 1;
Similarily there are about 4 queries which ae to be executed.
in a scenario like:
- inserting item sales to items table.
- updating the stock of all those items in the stock balance table.
- inseting the journal entries to the journal tables.
and so on.
Basically either all the queries should run or none of them runs.
Transactions are the way to go. http://www.devshed.com/c/a/MySQL/Using-Transactions-In-MySQL-Part-1/