title: How do detect that transaction has already been started?
body: <p>I am using Zend_Db to insert some data inside a transaction. My function starts a transaction and then calls another method that also attempts to start a transaction and of course fails(I am using MySQL5). So, the question is - how do I detect that transaction has already been  started? 
  Here is a sample bit of code:</p>
  
  <pre><code>       try {
                      Zend_Registry::get('database')-&gt;beginTransaction();
  
                      $totals = self::calculateTotals($Cart);
                      $PaymentInstrument = new PaymentInstrument;
                      $PaymentInstrument-&gt;create();
                      $PaymentInstrument-&gt;validate();
                      $PaymentInstrument-&gt;save();
  
                      Zend_Registry::get('database')-&gt;commit();
                      return true;
  
              } catch(Zend_Exception $e) {
                      Bootstrap::$Log-&gt;err($e-&gt;getMessage());
                      Zend_Registry::get('database')-&gt;rollBack();
                      return false;
              }
  </code></pre>
  
  <p>Inside PaymentInstrument::create there is another beginTransaction statement that produces the exception that says that transaction has already been started. </p>