diff options
author | Robin Appelman <icewind@owncloud.com> | 2015-08-10 14:15:44 +0200 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2015-08-10 14:15:44 +0200 |
commit | 58e96e53b039365751eb8c4a2d511fcfcf507891 (patch) | |
tree | 997d2a7726ba44601d6df3e95bfea5b08606a25a | |
parent | 06065189d768e5b33cb4798403db34b12cb60ef7 (diff) | |
download | nextcloud-server-58e96e53b039365751eb8c4a2d511fcfcf507891.tar.gz nextcloud-server-58e96e53b039365751eb8c4a2d511fcfcf507891.zip |
add method to check if we're inside a transaction
-rw-r--r-- | lib/private/appframework/db/db.php | 9 | ||||
-rw-r--r-- | lib/private/db/connection.php | 10 | ||||
-rw-r--r-- | lib/public/idbconnection.php | 8 |
3 files changed, 27 insertions, 0 deletions
diff --git a/lib/private/appframework/db/db.php b/lib/private/appframework/db/db.php index cde85831687..8e3fa6e4197 100644 --- a/lib/private/appframework/db/db.php +++ b/lib/private/appframework/db/db.php @@ -154,6 +154,15 @@ class Db implements IDb { } /** + * Check if a transaction is active + * + * @return bool + */ + public function inTransaction() { + return $this->connection->inTransaction(); + } + + /** * Commit the database changes done during a transaction that is in progress */ public function commit() { diff --git a/lib/private/db/connection.php b/lib/private/db/connection.php index def3f2fd120..4d33cd968af 100644 --- a/lib/private/db/connection.php +++ b/lib/private/db/connection.php @@ -291,4 +291,14 @@ class Connection extends \Doctrine\DBAL\Connection implements IDBConnection { protected function replaceTablePrefix($statement) { return str_replace( '*PREFIX*', $this->tablePrefix, $statement ); } + + /** + * Check if a transaction is active + * + * @return bool + * @since 8.2.0 + */ + public function inTransaction() { + return $this->getTransactionNestingLevel() > 0; + } } diff --git a/lib/public/idbconnection.php b/lib/public/idbconnection.php index 0d04c43d73e..6a4373583fa 100644 --- a/lib/public/idbconnection.php +++ b/lib/public/idbconnection.php @@ -115,6 +115,14 @@ interface IDBConnection { public function beginTransaction(); /** + * Check if a transaction is active + * + * @return bool + * @since 8.2.0 + */ + public function inTransaction(); + + /** * Commit the database changes done during a transaction that is in progress * @since 6.0.0 */ |