title: Halt mysql operations, until all return true
body: <p>I havn't been able to find an answer to this, and it may very well be because it has a name i don't know. Anywho.</p>
  
  <p>If you have multiple operations on a database, e.g:</p>
  
  <pre><code>if(insert_something_to_db($data) == TRUE){
       if(delete_something_else_from_db($data2) == TRUE){
            if(update_something_related_to_the_others_in_db($data3) == TRUE){
                 return TRUE;
            }
       } 
  } else { 
       return FALSE;
  }
  </code></pre>
  
  <p>If any of the nested queries fails, then the previous operations will have been concluded, which results in messy data in the database. Is it possible/is there some technique/best practice, to halt the execution of the operations, until you know if they all will be successful. </p>
  
  <p>I have an example:</p>
  
  <p>If a person wants to join a group, he clicks 'Join Group'
   - A notification is created in the db. This show up in the administration panel of the group owner.
   - The group owner can reject/accept the application.</p>
  
  <p>On Accept:
   - Applicant user data is updated with the new group information.
   - The Notification originally sent to the group administrator is going to be deleted
   - A new notification is created for the applicant, to inform him he was accepted.</p>
  
  <p>It is only if the outer most condition returns false (lets say user data updated), the actual db is holding the original data. If the first update goes through, but not the next, then the profile was updated to reflect the link with the new group, but the notification in the group administrators area is not gone. </p>
  
  <p>Regards
  Dennis</p>