add method to check if we're inside a transaction
This commit is contained in:
parent
06065189d7
commit
58e96e53b0
|
@ -153,6 +153,15 @@ class Db implements IDb {
|
||||||
$this->connection->beginTransaction();
|
$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
|
* 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) {
|
protected function replaceTablePrefix($statement) {
|
||||||
return str_replace( '*PREFIX*', $this->tablePrefix, $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();
|
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
|
* Commit the database changes done during a transaction that is in progress
|
||||||
* @since 6.0.0
|
* @since 6.0.0
|
||||||
|
|
Loading…
Reference in New Issue