Jump to content

langley

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

langley's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. thanks to everyone for their help - as a result it is now working ;D
  2. [b]CTM[/b]  - I realise that but if for whatever reason there is some kind of failiure to complete inserting of ALL users I need to take out any that may have been inserted by the loop thusfar and I'm trying to avoid going back and deleting each set of details from both tables 1 by 1 [b]shocker-z[/b] Thanks for the info -  I had a quick read and tried setting autocommit to 0 but it's still not rolling back. I'm finding it pretty confusing to figure out exactly what you can and can't do with transactions. Where you quoted "Do not use transactions (e.g. with InnoDB MySQL tables) with persistent connections." does that mean I have to reconnect for each query? if so it kind of defeats the object of me trying to use rollback. Sorry if these are dumb questions, I'm no master of this stuff!
  3. Hi, I have to insert multiple lines of user details into 2 different tables. I currently have a script that loops through the lines and adds accordingly. However if there is an error I need to undo all the entries I have made. Could somebody tell me will transaction rollback help me in this case? I currently have the following which is not working where the transaction code is out side the loop. I'm assuming this is wrong but I'm trying to find a way to avoid having to step back through 50 entries for example if the error is produced in the last line code follows - thanks for any help or info.... $how_many_errors=0; mysql_query('BEGIN TRANSACTION_NAME'); for($b=0;$b<$blah;$b++){ //do some SQL  queries if there is an error increment $how_many_errors } if($how_many_errors>0) { mysql_query('ROLLBACK'); } else {mysql_query('COMMIT');}
×
×
  • 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.