How to rollback changes made to a database with presence of Try Catch Statement in PHP?

You don't have to only have one action in each transaction. You can have multiple For example: When you go to the bank's atm: do you log in, get cash. Log out.

Log back in. Make a deposit. Log out.(and on..) OR Do you Log in.

Get cash, make deposit. (and on...) log out.?

You don't have to only have one action in each transaction. You can have multiple. For example: When you go to the bank's atm: do you log in, get cash.

Log out. Log back in. Make a deposit.

Log out. (and on..) OR Do you Log in. Get cash, make deposit.(and on...) log out.?

I already wrap multiple statements in a single try/catch (if that is what you are implying) but if an error occurs, the rollback only occurs on the table affected by the error. – JM4 Nov 4 at 16:11 @JM4 -- stackoverflow. Com/questions/3094398/… – Neal Nov 4 at 16:13 issue found, thanks for the link.

All of my tables are MyISAM – JM4 Nov 4 at 16:15.

The "easy" way would be to use ADOdb for PHP with InnoDB tables and the "mysqlt" database type. The DBAL takes care of keeping track of all the changes made during a transaction and will roll them back for you if asked.

Thanks for the suggestion. My Tables are in myisam format currently and I actually jsut spent quite a bit of time converting all of our code using PDO so not looking to switch again unless the benefits of such a switch are well worth the effort. – JM4 Nov 4 at 16:16 I would think that transactions shouldn't work (i.e.

Your call to $db->rollback() doesn't actually do anything) as MyISAM doesn't support transactions. – Crontab Nov 4 at 16:26 yep, see my comment above. Thanks for suggestion about ADOdb - i'll have to check it out.

– JM4 Nov 4 at 17:26 Right on, glad to help. Just keep in mind that for ADOdb to do transactions, the underlying tables have to support it also (it doesn't do artificial transactions). – Crontab Nov 4 at 17:51.

The easiest way to rollback changes is to make sure of three major things: Use START TRANSACTION/COMMIT or START TRANSACTION/ROLLBACK All tables used in the Transaction use the InnoDB Storage Engine Use CHECKPOINTs in the event you want to rollback some INSERTs/UPDATEs and not all CAVEAT : Please make sure you do not issue any of the following commands in the middle of a transaction because they launch an implicit COMMIT and begin a new transaction: ALTER TABLE BEGIN CREATE INDEX DROP DATABASAE DROP INDEX DROP TABLE RENAME TABLE TRUNCATE TABLE LOCK TABLES UNLOCK TABLES SET AUTOCOMMIT = 1 START TRANSACTION.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions