The method beginTransaction()
in class Zend_Db_Adapter_Abstract
is as follows:
public function beginTransaction()
{
$this->_connect();
$q = $this->_profiler->queryStart('begin', Zend_Db_Profiler::TRANSACTION);
$this->_beginTransaction();
$this->_profiler->queryEnd($q);
return $this;
}
In this method he calls the method _beginTransaction()
, which is abstract and should be implemented by the Zend Adapters. Therefore, from what I noticed in Zend’s code, there is no way to verify whether the transaction has already started or not. You should do this control in the application that uses Zend.
What you can do is enable the profiler (not recommended) and search through the method getProfiler()
. From it, get the profiles of each query by the method getQueryProfiles()
and check if any of them represent the start of a transaction.
However, as I said above, it is not recommended to leave the profiler enabled 100% of the time because it decreases the performance of the program. You can use it to debug your application and implement manual transaction control. :)
Very enlightening, I will wait a while to see if there are other possibilities, thank you.
– Kenny Rafael