当前位置: 首页>>代码示例>>PHP>>正文


PHP Connection::isTransactionActive方法代码示例

本文整理汇总了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();
 }
开发者ID:ngydat,项目名称:CoreBundle,代码行数:7,代码来源:TransactionalTestClient.php

示例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;
 }
开发者ID:BozzaCoon,项目名称:SPHERE-Framework,代码行数:12,代码来源:SQLAzureShardManager.php

示例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();
             }
         }
     });
 }
开发者ID:brick,项目名称:app,代码行数:21,代码来源:TransactionalPlugin.php

示例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;
 }
开发者ID:neteasy-work,项目名称:hkgbf_crm,代码行数:16,代码来源:SQLAzureShardManager.php

示例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());
     }
 }
开发者ID:drognisep,项目名称:Portfolio-Site,代码行数:28,代码来源:Migrator.php

示例6: testNoTransactionActiveByDefault

 public function testNoTransactionActiveByDefault()
 {
     $this->assertFalse($this->_conn->isTransactionActive());
 }
开发者ID:llinder,项目名称:FrameworkBenchmarks,代码行数:4,代码来源:ConnectionTest.php

示例7: isTransactionActive

 /**
  * {@inheritDoc}
  */
 public function isTransactionActive()
 {
     $this->setTransactionNestingLevel($this->getPersistedTransactionNestingLevel());
     return parent::isTransactionActive();
 }
开发者ID:ruslan-polutsygan,项目名称:dev-bundle,代码行数:8,代码来源:PersistedConnection.php

示例8: isTransactionActive

 /**
  * @return bool
  */
 public function isTransactionActive()
 {
     return $this->connection->isTransactionActive();
 }
开发者ID:arnaud-23,项目名称:UseCaseBundle,代码行数:7,代码来源:DoctrineDBALConnectionTransactionAdapter.php

示例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());
 }
开发者ID:selimcr,项目名称:servigases,代码行数:18,代码来源:ConnectionTest.php

示例10: rollback

 /**
  * Safe rollback.
  *
  * @return void
  */
 public function rollback()
 {
     if ($this->db->isTransactionActive()) {
         $this->db->rollBack();
     }
 }
开发者ID:lokhman,项目名称:silex-arm,代码行数:11,代码来源:Repository.php


注:本文中的Doctrine\DBAL\Connection::isTransactionActive方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。