TransactionManager.php
Same filename in this branch
Same filename and directory in other branches
- 11.x core/modules/sqlite/src/Driver/Database/sqlite/TransactionManager.php
- 11.x core/modules/mysql/src/Driver/Database/mysql/TransactionManager.php
- 11.x core/modules/pgsql/src/Driver/Database/pgsql/TransactionManager.php
- 11.x core/modules/mysqli/src/Driver/Database/mysqli/TransactionManager.php
- 10 core/modules/sqlite/src/Driver/Database/sqlite/TransactionManager.php
- 10 core/modules/mysql/src/Driver/Database/mysql/TransactionManager.php
- 10 core/modules/pgsql/src/Driver/Database/pgsql/TransactionManager.php
Namespace
Drupal\mysql\Driver\Database\mysqlFile
-
core/
modules/ mysql/ src/ Driver/ Database/ mysql/ TransactionManager.php
View source
<?php
declare (strict_types=1);
namespace Drupal\mysql\Driver\Database\mysql;
use Drupal\Core\Database\Transaction\TransactionManagerBase;
use Drupal\Core\Database\TransactionCommitFailedException;
use Drupal\Core\Database\TransactionException;
use Drupal\Core\Database\TransactionNoActiveException;
/**
* 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.
*/
class TransactionManager extends TransactionManagerBase {
/**
* {@inheritdoc}
*/
protected function beginClientTransaction() : bool {
try {
return $this->connection
->getClientConnection()
->beginTransaction();
} catch (\Exception $e) {
throw new TransactionException('Failed start of transaction', $e->getCode(), $e);
}
}
/**
* {@inheritdoc}
*/
protected function rollbackClientSavepoint(string $name) : bool {
if (!$this->connection
->getClientConnection()
->inTransaction()) {
throw new TransactionNoActiveException();
}
return parent::rollbackClientSavepoint($name);
}
/**
* {@inheritdoc}
*/
protected function releaseClientSavepoint(string $name) : bool {
if (!$this->connection
->getClientConnection()
->inTransaction()) {
throw new TransactionNoActiveException();
}
return parent::releaseClientSavepoint($name);
}
/**
* {@inheritdoc}
*/
protected function commitClientTransaction() : bool {
try {
return $this->connection
->getClientConnection()
->commit();
} catch (\Exception $e) {
throw new TransactionCommitFailedException('Failed commit of transaction', $e->getCode(), $e);
}
}
/**
* {@inheritdoc}
*/
protected function rollbackClientTransaction() : bool {
if (!$this->connection
->getClientConnection()
->inTransaction()) {
throw new TransactionNoActiveException();
}
try {
return $this->connection
->getClientConnection()
->rollBack();
} catch (\Exception $e) {
throw new TransactionException('Failed rollback of transaction', $e->getCode(), $e);
}
}
}
Classes
| Title | Deprecated | Summary |
|---|---|---|
| TransactionManager | MySql implementation of TransactionManagerInterface. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.