title: PDO MySQL Transactions
body: <p>I have 3 queries regarding PDO and Transactions.
  I'm pretty new at transactions, so please understand my misunderstandings!</p>
  
  <p>First, i'll explain the situation: 
  I have created a PDO wrapper in a singleton pattern, which accesses a MySQL database with innoDB tables. The reason I've created a wrapper is to provide extra functionality and improve portability.</p>
  
  <p>Each time an object needs access to the database, it retrieves the same connection.</p>
  
  <p>My questions are as follow:</p>
  
  <p>1) I understand if I begin a transaction with <code>PDO::beginTransaction()</code>, then that sets MySQLs autocommit mode to off. However does this affect just the current users connection to the database, or every visitors connection, since its the database which contains the autocommit value, not the PHP script?</p>
  
  <p>2) I have a need to perform MySQL queries which are not relevant to the actual transaction. These queries are performed in unrelated objects, however still use the same MySQL connection as the transaction. 
  I've just found out that the unrelated (to the transaction) queries are still being included in the transaction, which is causing undesired effects. Is there any way around this? Or is my PHP design incorrect for this use of transactions?</p>
  
  <p>3) I'm using PHP 5.1. It supports the following functions: <code>PDO::beginTransaction()</code>, <code>PDO::commit()</code> and <code>PDO::rollBack()</code>.</p>
  
  <p>I understand that if I call <code>PDO::rollBack()</code>, when a transaction is not in effect, a PDOException is thrown. The solution to this is to use <code>PDO::inTransaction()</code> to check for transactions before using rollBack(), however this isn't added to PHP until 5.3. </p>
  
  <p>At the moment, when my wrapper starts a transaction, it updates a static variable to true, and when its rolled back, or committed, it sets the variable back to false. Is this a good solution? Or is there a pre-existing solution I'm unaware of?</p>
  
  <p>Many thanks for your help</p>