add method to check if we're inside a transaction

remotes/origin/notification-style
Robin Appelman 11 years ago
parent 06065189d7
commit 58e96e53b0
  1. 9
      lib/private/appframework/db/db.php
  2. 10
      lib/private/db/connection.php
  3. 8
      lib/public/idbconnection.php

@ -153,6 +153,15 @@ class Db implements IDb {
$this->connection->beginTransaction();
}
/**
* 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
*/

@ -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;
}
}

@ -114,6 +114,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

Loading…
Cancel
Save