PHPLOVER PHPLOVER - 1 year ago 47
PHP Question

How to make sure two MySQL queries are successful?

I have two MySQL queries in my PHP code.

Basically I need the two queries to execute (they are two INSERT) queries and both must be successful. If for example query1 is successful but query2 is not successful; I need to rollback query1 as both queries must be successful.

I am using MyISAM and I know I cannot do rollbacks etc but is there any way I can overcome my problem (another solution) to do what I want?

They both depend on each other as query1 stores data from form and query2 inserts some other details into another table (it's basically a counter) that tracks total counts for a referral system.

Answer Source

Sounds to me like you need transactions.

They allow you to rollback an entire series of database modifications within a single transaction.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download