From 45d41f1c9b465a70978c20a8d966d9b434985f7b Mon Sep 17 00:00:00 2001 From: romanb Date: Thu, 20 Mar 2008 15:17:01 +0000 Subject: [PATCH] merged fix for #873 from 0.10 --- lib/Doctrine/Transaction.php | 30 +++++++++++++++++++++++++++--- lib/Doctrine/Transaction/Mssql.php | 24 ++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 3 deletions(-) diff --git a/lib/Doctrine/Transaction.php b/lib/Doctrine/Transaction.php index a8110bc9f..712ece4c3 100644 --- a/lib/Doctrine/Transaction.php +++ b/lib/Doctrine/Transaction.php @@ -222,7 +222,7 @@ class Doctrine_Transaction extends Doctrine_Connection_Module if ( ! $event->skipOperation) { try { - $this->conn->getDbh()->beginTransaction(); + $this->_doBeginTransaction(); } catch (Exception $e) { throw new Doctrine_Transaction_Exception($e->getMessage()); } @@ -292,7 +292,7 @@ class Doctrine_Transaction extends Doctrine_Connection_Module $listener->preTransactionCommit($event); if ( ! $event->skipOperation) { - $this->conn->getDbh()->commit(); + $this->_doCommit(); } $listener->postTransactionCommit($event); } @@ -355,7 +355,7 @@ class Doctrine_Transaction extends Doctrine_Connection_Module $this->_nestingLevel = 0; $this->_internalNestingLevel = 0; try { - $this->conn->getDbh()->rollback(); + $this->_doRollback(); } catch (Exception $e) { throw new Doctrine_Transaction_Exception($e->getMessage()); } @@ -401,6 +401,30 @@ class Doctrine_Transaction extends Doctrine_Connection_Module { throw new Doctrine_Transaction_Exception('Savepoints not supported by this driver.'); } + + /** + * Performs the rollback. + */ + protected function _doRollback() + { + $this->conn->getDbh()->rollback(); + } + + /** + * Performs the commit. + */ + protected function _doCommit() + { + $this->conn->getDbh()->commit(); + } + + /** + * Begins a database transaction. + */ + protected function _doBeginTransaction() + { + $this->conn->getDbh()->beginTransaction(); + } /** * removeSavePoints diff --git a/lib/Doctrine/Transaction/Mssql.php b/lib/Doctrine/Transaction/Mssql.php index d5a81bfef..66c25e95d 100644 --- a/lib/Doctrine/Transaction/Mssql.php +++ b/lib/Doctrine/Transaction/Mssql.php @@ -65,4 +65,28 @@ class Doctrine_Transaction_Mssql extends Doctrine_Transaction $this->conn->execute($query); } + + /** + * Performs the rollback. + */ + protected function _doRollback() + { + $this->conn->getDbh()->exec('ROLLBACK TRANSACTION'); + } + + /** + * Performs the commit. + */ + protected function _doCommit() + { + $this->conn->getDbh()->exec('COMMIT TRANSACTION'); + } + + /** + * Begins a database transaction. + */ + protected function _doBeginTransaction() + { + $this->conn->getDbh()->exec('BEGIN TRANSACTION'); + } } \ No newline at end of file