class TransactionManager
Same name in this branch
- 11.x core/modules/sqlite/src/Driver/Database/sqlite/TransactionManager.php \Drupal\sqlite\Driver\Database\sqlite\TransactionManager
- 11.x core/modules/pgsql/src/Driver/Database/pgsql/TransactionManager.php \Drupal\pgsql\Driver\Database\pgsql\TransactionManager
Same name in other branches
- 10 core/modules/sqlite/src/Driver/Database/sqlite/TransactionManager.php \Drupal\sqlite\Driver\Database\sqlite\TransactionManager
- 10 core/modules/mysql/src/Driver/Database/mysql/TransactionManager.php \Drupal\mysql\Driver\Database\mysql\TransactionManager
- 10 core/modules/pgsql/src/Driver/Database/pgsql/TransactionManager.php \Drupal\pgsql\Driver\Database\pgsql\TransactionManager
MySql implementation of TransactionManagerInterface.
MySQL will automatically commit transactions when tables are altered or created (DDL transactions are not supported). However, pdo_mysql tracks whether a client connection is still active and we can prevent triggering exceptions.
Hierarchy
- class \Drupal\mysql\Driver\Database\mysql\TransactionManager extends \Drupal\Core\Database\Transaction\TransactionManagerBase
Expanded class hierarchy of TransactionManager
File
-
core/
modules/ mysql/ src/ Driver/ Database/ mysql/ TransactionManager.php, line 18
Namespace
Drupal\mysql\Driver\Database\mysqlView source
class TransactionManager extends TransactionManagerBase {
/**
* {@inheritdoc}
*/
protected function beginClientTransaction() : bool {
return $this->connection
->getClientConnection()
->beginTransaction();
}
/**
* {@inheritdoc}
*/
protected function processRootCommit() : void {
if (!$this->connection
->getClientConnection()
->inTransaction()) {
$this->voidClientTransaction();
return;
}
parent::processRootCommit();
}
/**
* {@inheritdoc}
*/
protected function rollbackClientSavepoint(string $name) : bool {
if (!$this->connection
->getClientConnection()
->inTransaction()) {
$this->voidClientTransaction();
return TRUE;
}
return parent::rollbackClientSavepoint($name);
}
/**
* {@inheritdoc}
*/
protected function releaseClientSavepoint(string $name) : bool {
if (!$this->connection
->getClientConnection()
->inTransaction()) {
$this->voidClientTransaction();
return TRUE;
}
return parent::releaseClientSavepoint($name);
}
/**
* {@inheritdoc}
*/
protected function commitClientTransaction() : bool {
$clientCommit = $this->connection
->getClientConnection()
->commit();
$this->setConnectionTransactionState($clientCommit ? ClientConnectionTransactionState::Committed : ClientConnectionTransactionState::CommitFailed);
return $clientCommit;
}
/**
* {@inheritdoc}
*/
protected function rollbackClientTransaction() : bool {
if (!$this->connection
->getClientConnection()
->inTransaction()) {
$this->voidClientTransaction();
return FALSE;
}
$clientRollback = $this->connection
->getClientConnection()
->rollBack();
$this->setConnectionTransactionState($clientRollback ? ClientConnectionTransactionState::RolledBack : ClientConnectionTransactionState::RollbackFailed);
return $clientRollback;
}
}
Members
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.