View Single Post
Old 07-29-2009, 06:54 PM   #1 (permalink)
captainmerton
The Acquainted
 
captainmerton's Avatar
 
Join Date: May 2009
Posts: 178
Thanks: 9
captainmerton is on a distinguished road
Default mysql ROLLBACK & COMMIT

I'm looking for some guidance on how to use mysql BEGIN, ROLLBACK and COMMITS. I have situations where i am making 2 or 3 updates to tables in seperate queries and if one fails i want them all rolled back. Can someone help me with the following:

Whats the difference between BEGIN and START TRANSACTION?

How can I best incorporate error handling eg. at present i'm running queries using the following code:

PHP Code:
$result mysql_query($query) OR die('Cannot perform query!'.mysql_error()); 
On a die statement does mysql look back for a BEGIN or START TRANSACTION and roll back to there or will I have to tell it to ROLLBACK?
captainmerton is offline  
Reply With Quote