本文整理汇总了PHP中Doctrine\DBAL\Connection::isTransactionActive方法的典型用法代码示例。如果您正苦于以下问题:PHP Connection::isTransactionActive方法的具体用法?PHP Connection::isTransactionActive怎么用?PHP Connection::isTransactionActive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\DBAL\Connection
的用法示例。
在下文中一共展示了Connection::isTransactionActive方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: shutdown
public function shutdown()
{
if ($this->connection->isTransactionActive()) {
$this->rollback();
}
$this->connection->close();
}
示例2: selectGlobal
/**
* {@inheritDoc}
*/
public function selectGlobal()
{
if ($this->conn->isTransactionActive()) {
throw ShardingException::activeTransaction();
}
$sql = "USE FEDERATION ROOT WITH RESET";
$this->conn->exec($sql);
$this->currentDistributionValue = null;
}
示例3: register
/**
* {@inheritdoc}
*/
public function register(EventDispatcher $dispatcher)
{
$dispatcher->addListener(RouteMatchedEvent::class, function (RouteMatchedEvent $event) {
$annotation = $this->getTransactionalAnnotation($event->getRouteMatch());
if ($annotation) {
$this->connection->setTransactionIsolation($annotation->getIsolationLevel());
$this->connection->beginTransaction();
}
});
$dispatcher->addListener(ControllerInvocatedEvent::class, function (ControllerInvocatedEvent $event) {
$annotation = $this->getTransactionalAnnotation($event->getRouteMatch());
if ($annotation) {
if ($this->connection->isTransactionActive()) {
$this->connection->rollback();
}
}
});
}
示例4: selectShard
/**
* {@inheritDoc}
*/
public function selectShard($distributionValue)
{
if ($this->conn->isTransactionActive()) {
throw ShardingException::activeTransaction();
}
if ($distributionValue === null || is_bool($distributionValue) || !is_scalar($distributionValue)) {
throw ShardingException::noShardDistributionValue();
}
$platform = $this->conn->getDatabasePlatform();
$sql = sprintf("USE FEDERATION %s (%s = %s) WITH RESET, FILTERING = %s;", $platform->quoteIdentifier($this->federationName), $platform->quoteIdentifier($this->distributionKey), $this->conn->quote($distributionValue), $this->filteringEnabled ? 'ON' : 'OFF');
$this->conn->exec($sql);
$this->currentDistributionValue = $distributionValue;
}
示例5: checkTableMigrate
/**
* Check the migration of a table on a copy so we can detect errors before messing with the real table
*
* @param \Doctrine\DBAL\Schema\Table $table
* @throws \OC\DB\MigrationException
*/
protected function checkTableMigrate(Table $table)
{
$name = $table->getName();
$tmpName = $this->generateTemporaryTableName($name);
$this->copyTable($name, $tmpName);
//create the migration schema for the temporary table
$tmpTable = $this->renameTableSchema($table, $tmpName);
$schemaConfig = new SchemaConfig();
$schemaConfig->setName($this->connection->getDatabase());
$schema = new Schema(array($tmpTable), array(), $schemaConfig);
try {
$this->applySchema($schema);
$this->dropTable($tmpName);
} catch (DBALException $e) {
// pgsql needs to commit it's failed transaction before doing anything else
if ($this->connection->isTransactionActive()) {
$this->connection->commit();
}
$this->dropTable($tmpName);
throw new MigrationException($table->getName(), $e->getMessage());
}
}
示例6: testNoTransactionActiveByDefault
public function testNoTransactionActiveByDefault()
{
$this->assertFalse($this->_conn->isTransactionActive());
}
示例7: isTransactionActive
/**
* {@inheritDoc}
*/
public function isTransactionActive()
{
$this->setTransactionNestingLevel($this->getPersistedTransactionNestingLevel());
return parent::isTransactionActive();
}
示例8: isTransactionActive
/**
* @return bool
*/
public function isTransactionActive()
{
return $this->connection->isTransactionActive();
}
示例9: testSwitchingAutoCommitModeCommitsAllCurrentTransactions
/**
* @group DBAL-81
*/
public function testSwitchingAutoCommitModeCommitsAllCurrentTransactions()
{
$driverMock = $this->getMock('Doctrine\\DBAL\\Driver');
$driverMock->expects($this->any())->method('connect')->will($this->returnValue(new DriverConnectionMock()));
$conn = new Connection(array('platform' => new Mocks\MockPlatform()), $driverMock);
$conn->connect();
$conn->beginTransaction();
$conn->beginTransaction();
$conn->setAutoCommit(false);
$this->assertSame(1, $conn->getTransactionNestingLevel());
$conn->beginTransaction();
$conn->beginTransaction();
$conn->setAutoCommit(true);
$this->assertFalse($conn->isTransactionActive());
}
示例10: rollback
/**
* Safe rollback.
*
* @return void
*/
public function rollback()
{
if ($this->db->isTransactionActive()) {
$this->db->rollBack();
}
}