diff options
author | Meik Sievertsen <acydburn@phpbb.com> | 2007-05-05 10:22:24 +0000 |
---|---|---|
committer | Meik Sievertsen <acydburn@phpbb.com> | 2007-05-05 10:22:24 +0000 |
commit | a5704a0b01b2f549aad0c1722ae3b136a9c55f1e (patch) | |
tree | 44092e3287dc4f91d494073f541675f7f4475412 /phpBB/includes/db/dbal.php | |
parent | eee1dedc13627283dfc1cfc5aa00f769fa061df7 (diff) | |
download | forums-a5704a0b01b2f549aad0c1722ae3b136a9c55f1e.tar forums-a5704a0b01b2f549aad0c1722ae3b136a9c55f1e.tar.gz forums-a5704a0b01b2f549aad0c1722ae3b136a9c55f1e.tar.bz2 forums-a5704a0b01b2f549aad0c1722ae3b136a9c55f1e.tar.xz forums-a5704a0b01b2f549aad0c1722ae3b136a9c55f1e.zip |
Better support for nested transactions...
git-svn-id: file:///svn/phpbb/trunk@7469 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/db/dbal.php')
-rw-r--r-- | phpBB/includes/db/dbal.php | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/phpBB/includes/db/dbal.php b/phpBB/includes/db/dbal.php index cfd13fd118..0001073319 100644 --- a/phpBB/includes/db/dbal.php +++ b/phpBB/includes/db/dbal.php @@ -38,6 +38,9 @@ class dbal // Holding the last sql query on sql error var $sql_error_sql = ''; + // Holding transaction count + var $transactions = 0; + // Supports multi inserts? var $multi_insert = false; @@ -197,29 +200,46 @@ class dbal switch ($status) { case 'begin': - // Commit previously opened transaction before opening another transaction + // If we are within a transaction we will not open another one, but enclose the current one to not loose data (prevening auto commit) if ($this->transaction) { - $this->_sql_transaction('commit'); + $this->transactions++; + return true; } $result = $this->_sql_transaction('begin'); + + if (!$result) + { + $this->sql_error(); + } + $this->transaction = true; break; case 'commit': + // If there was a previously opened transaction we do not commit yet... but count back the number of inner transactions + if ($this->transaction && $this->transactions) + { + $this->transactions--; + return true; + } + $result = $this->_sql_transaction('commit'); - $this->transaction = false; if (!$result) { - $this->_sql_transaction('rollback'); + $this->sql_error(); } + + $this->transaction = false; + $this->transactions = 0; break; case 'rollback': $result = $this->_sql_transaction('rollback'); $this->transaction = false; + $this->transactions = 0; break; default: |