title: MySQL commit and transaction
body: <p>I have a question regarding MySQL commits and transactions. I have a couple of PHP statements that execute MySQL queries. Do I just say the following?</p>
  <pre><code>mysql_query(&quot;START TRANSACTION&quot;);
  //more queries here
  mysql_query(&quot;COMMIT&quot;);
  </code></pre>
  <p>What exactly would this do? How does it help? For updates, deletes and insertions I also found this to block other queries from reading:</p>
  <pre><code>mysql_query(&quot;LOCK TABLES t1 WRITE, t2 WRITE&quot;);
  //more queries here
  mysql_query(&quot;UNLOCK TABLES t1, t2&quot;);
  </code></pre>
  <p>Would this block other queries whatever nature or only writes/selects?</p>
  <p>Another question: Say one query is running and blocks other queries. Another query tries to access blocked data - and it sees that it is blocked. How does it proceed? Does it wait until the data is unblocked again and re-execute the query? Does it just fail and needs to be repeated? If so, how can I check?</p>
  <p>Thanks a lot!</p>
  <p>Dennis</p>