Jump to content

MySql Transaction Rollback with multiple queries


Recommended Posts

I am trying to rollback more than one insert statment inside a transaction.  I thought everything was working fine; however, i'm not sure if its my new hosting.  Only the first query of the set seem to rollback.

 

Here is an example:

mysql_query("BEGIN");

$result = array();
$result = mysql_query($insert_1);
$result = mysql_query($insert_2);
$result = mysql_query($insert_3);
$result = mysql_query($insert_4);

if(!in_array(null, $result)){
  mysql_query("COMMIT");
}
else{
  mysql_query("ROLLBACK");
}

 

Basically, only insert_1 gets rolled back.  I thought on my old server the whole set rolled back, but I can't be 100% sure.

 

Any suggestions?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.