From 60a13c3cd8da3c6dbd4586d218fd67a287090e7c Mon Sep 17 00:00:00 2001 From: steinm Date: Mon, 22 Oct 2012 06:26:30 +0000 Subject: [PATCH] - added methods for transaction handling --- LetoDMS_Core/Core/inc.DBAccess.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/LetoDMS_Core/Core/inc.DBAccess.php b/LetoDMS_Core/Core/inc.DBAccess.php index 9dd059ce4..fdef9dd5a 100644 --- a/LetoDMS_Core/Core/inc.DBAccess.php +++ b/LetoDMS_Core/Core/inc.DBAccess.php @@ -39,6 +39,7 @@ class LetoDMS_Core_DatabaseAccess { var $_ttapproveid; var $_ttstatid; var $_ttcontentid; + var $_intransaction; /* Backup functions @@ -73,6 +74,7 @@ class LetoDMS_Core_DatabaseAccess { $this->_user = $user; $this->_passw = $passw; $this->_connected = false; + $this->_intransaction = 0; // $tt*****id is a hack to ensure that we do not try to create the // temporary table twice during a single connection. Can be fixed by // using Views (MySQL 5.0 onward) instead of temporary tables. @@ -184,6 +186,27 @@ class LetoDMS_Core_DatabaseAccess { return $this->_conn->Insert_ID(); } /* }}} */ + function startTransaction() { /* {{{ */ + if(!$this->_intransaction) { + $this->_conn->BeginTrans(); + } + $this->_intransaction++; + } /* }}} */ + + function rollbackTransaction() { /* {{{ */ + if($this->_intransaction == 1) { + $this->_conn->RollbackTrans(); + } + $this->_intransaction--; + } /* }}} */ + + function commitTransaction() { /* {{{ */ + if($this->_intransaction == 1) { + $this->_conn->CommitTrans(); + } + $this->_intransaction--; + } /* }}} */ + function getErrorMsg() { /* {{{ */ return $this->_conn->ErrorMsg(); } /* }}} */