title: PHP & mySQL: Simple code to implement Transaction - Commit & Rollback
body: <p><strong>MY PLATFORM:</strong></p>
  
  <p>PHP &amp; mySQL</p>
  
  <p><strong>MY SITUATION:</strong></p>
  
  <p>I am trying to implement transactions within my code. I tried to follow examples, but it's not much help. I am running 3 queries and I wanted to write a transaction in such a way so that if any of the query(ies) fail, the whole transaction should roll back. I would really appreciate a simple, efficient and <strong>non-object oriented PHP code</strong> to achieve this goal. Thank you in advance.</p>
  
  <p><strong>MY PHP CODE:</strong></p>
  
  <pre><code>//db_res calls a custom function that performs a mysql_query on the query
  $res1 = db_res("SELECT c1, c2 FROM t1 WHERE c5 = 3");
  $res2 = db_res("UPDATE t2 SET c1 = 5 WHERE c2 = 10");
  $res3 = db_res("DELETE FROM t3 WHERE c1 = 20");
  
  if( $res1 &amp;&amp; $res2 &amp;&amp; $res3 )
  {
   //commit --- but how?
  }
  else
  {
   //rollback --- but how?
  }
  </code></pre>