- added methods for transaction handling

This commit is contained in:
steinm 2012-10-22 06:26:30 +00:00
parent a38a7283cd
commit 60a13c3cd8

View File

@ -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();
} /* }}} */