Welcome Guest, Not a member yet? Register   Sign In
Database Transaction Error Handling

I have a lengthy script that is responsible for making many DB changes that are all required to complete for the operation to be successful, so I've wrapped them in a transaction. This script is also responsible for authorizing a payment before any database changes occur, and then capturing and actually charging the account after the changes are complete. I've included a check on $this->db->trans_status() === FALSE to see if the transaction failed, and if so then void the previously authorized payment, return errors to the user, etc. The problem I'm having is that say, for example, query 4 of 12 fails. The transaction is rolled back as it should, and I get the CI database error page displayed. The payment however is never voided, so it seems to me that as soon as the error occurs the script execution stops and it never gets to my trans_status check. I'm thinking that the only way to fix this is to check trans_status() after each and every call to the database, which seems kind of messy. Does anyone have a better way of handling this kind of process?

Theme © iAndrew 2016 - Forum software by © MyBB