From 0c6fa4ad25c64fa4033838feb298c92edd1651b4 Mon Sep 17 00:00:00 2001 From: xue <> Date: Wed, 12 Mar 2008 18:15:01 +0000 Subject: fixed #741. --- framework/Data/TDbConnection.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'framework/Data') diff --git a/framework/Data/TDbConnection.php b/framework/Data/TDbConnection.php index 23a6e58b..1f2782db 100644 --- a/framework/Data/TDbConnection.php +++ b/framework/Data/TDbConnection.php @@ -85,6 +85,7 @@ class TDbConnection extends TComponent private $_attributes=array(); private $_active=false; private $_pdo=null; + private $_transaction; /** * Constructor. @@ -249,6 +250,19 @@ class TDbConnection extends TComponent throw new TDbException('dbconnection_connection_inactive'); } + /** + * @return CDbTransaction the currently active transaction. Null if no active transaction. + */ + public function getCurrentTransaction() + { + if($this->_transaction!==null) + { + if($this->_transaction->getActive()) + return $this->_transaction; + } + return null; + } + /** * Starts a transaction. * @return TDbTransaction the transaction initiated @@ -259,7 +273,7 @@ class TDbConnection extends TComponent if($this->getActive()) { $this->_pdo->beginTransaction(); - return new TDbTransaction($this); + return $this->_transaction=new TDbTransaction($this); } else throw new TDbException('dbconnection_connection_inactive'); -- cgit v1.2.3