Nehajha has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/401704 )

Change subject: Added methods for starting, committing and rolling back 
transactions
......................................................................

Added methods for starting, committing and rolling back transactions

Change-Id: I69da09ac3474ab5a9f1a59b15e691ffd70182d6c
---
M src/Dao/AbstractDao.php
1 file changed, 27 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikimedia/slimapp 
refs/changes/04/401704/1

diff --git a/src/Dao/AbstractDao.php b/src/Dao/AbstractDao.php
index d0c2f6f..b608578 100644
--- a/src/Dao/AbstractDao.php
+++ b/src/Dao/AbstractDao.php
@@ -44,6 +44,7 @@
         * @var LoggerInterface $logger
         */
        protected $logger;
+       protected $transactionCounter = 0;
 
        /**
         * @param string $dsn PDO data source name
@@ -62,6 +63,32 @@
                );
        }
 
+       protected function transactionStart() {
+               if ( $this->transactionCounter == 0 ) {
+                       $this->transactionCounter++;
+                       return $this->dbh->begintransaction();
+               }
+               $this->transactionCounter++;
+               return $this->transactionCounter >= 0;
+       }
+
+       protected function transactionCommit() {
+               $this->transactionCounter--;
+               if ( $this->transactionCounter == 0 ) {
+                       return $this->dbh->commit();
+               }
+               return $this->transactionCounter >= 0;
+       }
+
+       protected function transactionRollback() {
+               if ( $this->transactionCounter >= 0 ) {
+                       $this->transactionCounter = 0;
+                       return $this->dbh->rollback();
+               }
+               $this->transactionCounter = 0;
+               return false;
+       }
+
        /**
         * Bind values to a prepared statement.
         *

-- 
To view, visit https://gerrit.wikimedia.org/r/401704
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I69da09ac3474ab5a9f1a59b15e691ffd70182d6c
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/slimapp
Gerrit-Branch: master
Gerrit-Owner: Nehajha <nj4...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to