當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Connection::close方法代碼示例

本文整理匯總了PHP中Doctrine\DBAL\Connection::close方法的典型用法代碼示例。如果您正苦於以下問題:PHP Connection::close方法的具體用法?PHP Connection::close怎麽用?PHP Connection::close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Doctrine\DBAL\Connection的用法示例。


在下文中一共展示了Connection::close方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: shutdown

 public function shutdown()
 {
     if ($this->connection->isTransactionActive()) {
         $this->rollback();
     }
     $this->connection->close();
 }
開發者ID:ngydat,項目名稱:CoreBundle,代碼行數:7,代碼來源:TransactionalTestClient.php

示例2: getConnection

 /**
  * @return Connection
  */
 public function getConnection()
 {
     if (false === $this->connection->ping()) {
         $this->connection->close();
         $this->connection->connect();
     }
     return $this->connection;
 }
開發者ID:krowinski,項目名稱:php-mysql-replication,代碼行數:11,代碼來源:MySQLRepository.php

示例3: singleImport

 private function singleImport($config, OutputInterface &$output, $entity_key = null)
 {
     $this->connection = $this->connectionFactory->createConnection($config['database']);
     $this->connection->getConfiguration()->getSQLLogger(null);
     if ($entity_key) {
         if (!isset($config['maps'][$entity_key])) {
             throw new \Exception("Entity alias not found: " . $entity_key);
         }
         $map = $config['maps'][$entity_key];
         if (!$this->container->has($map['old_data']['service_id'])) {
             throw new \Exception("Service not exists: " . $map['old_data']['service_id']);
         }
         $result = $this->importEntity($map);
         $output->writeln("<info>Total " . count($result) . " {$entity_key} imported </info>");
     } else {
         foreach ((array) $config['maps'] as $key => $map) {
             if (!$this->container->has($map['old_data']['service_id'])) {
                 throw new \Exception("Service not exists: " . $map['old_data']['service_id']);
             }
             $offset = 0;
             do {
                 $result = $this->importEntity($map);
                 $output->writeln("<info>Total " . count($result) . " {$key} imported </info>");
                 if (!$result) {
                     break;
                 }
                 $offset++;
                 $this->setOffset($offset);
             } while (true);
         }
     }
     $this->connection->close();
 }
開發者ID:hmert,項目名稱:importbundle,代碼行數:33,代碼來源:ImportManager.php

示例4: pingIt

 protected function pingIt(Connection $con)
 {
     if ($con->ping() === false) {
         $con->close();
         $con->connect();
     }
     return $con;
 }
開發者ID:arnulfojr,項目名稱:qcharts,代碼行數:8,代碼來源:DynamicEntityManager.php

示例5: getConnection

 /**
  * Retrieves hte index database.
  *
  * @return Connection
  */
 public function getConnection()
 {
     if (!$this->connection) {
         $isNewDatabase = !file_exists($this->databasePath);
         $configuration = new Configuration();
         $this->connection = DriverManager::getConnection(['driver' => 'pdo_sqlite', 'path' => $this->databasePath], $configuration);
         $outOfDate = null;
         if ($isNewDatabase) {
             $this->createDatabaseTables($this->connection);
             // NOTE: This causes a database write and will cause locking problems if multiple PHP processes are
             // spawned and another one is also writing (e.g. indexing).
             $this->connection->executeQuery('PRAGMA user_version=' . $this->databaseVersion);
         } else {
             $version = $this->connection->executeQuery('PRAGMA user_version')->fetchColumn();
             if ($version < $this->databaseVersion) {
                 $this->connection->close();
                 $this->connection = null;
                 @unlink($this->databasePath);
                 return $this->getConnection();
                 // Do it again.
             }
         }
     }
     // Have to be a douche about this as these PRAGMA's seem to reset, even though the connection is not closed.
     $this->connection->executeQuery('PRAGMA foreign_keys=ON');
     // Data could become corrupted if the operating system were to crash during synchronization, but this
     // matters very little as we will just reindex the project next time. In the meantime, this majorly reduces
     // hard disk I/O during indexing and increases indexing speed dramatically (dropped from over a minute to a
     // couple of seconds for a very small (!) project).
     $this->connection->executeQuery('PRAGMA synchronous=OFF');
     return $this->connection;
 }
開發者ID:tocjent,項目名稱:php-integrator-base,代碼行數:37,代碼來源:IndexDatabase.php

示例6: resetSharedConn

 protected function resetSharedConn()
 {
     if (self::$_sharedConn) {
         self::$_sharedConn->close();
         self::$_sharedConn = null;
     }
 }
開發者ID:llinder,項目名稱:FrameworkBenchmarks,代碼行數:7,代碼來源:DbalFunctionalTestCase.php

示例7: reconnectIfNecessary

 /**
  * This method checks whether the connection is still open or reconnects otherwise.
  *
  * The connection might drop in some scenarios, where the server has a configured timeout and the handling
  * of the result set takes longer. To prevent failures of the dumper, the connection will be opened again.
  */
 public function reconnectIfNecessary()
 {
     if (!$this->connection->ping()) {
         $this->connection->close();
         $this->connect();
     }
 }
開發者ID:digilist,項目名稱:snakedumper,代碼行數:13,代碼來源:ConnectionHandler.php

示例8: tearDown

 public function tearDown()
 {
     $this->connection->close();
     $this->eventStore = null;
     $this->eventNameResolver = null;
     $this->serializer = null;
     $this->connection = null;
 }
開發者ID:simple-es,項目名稱:doctrine-dbal-bridge,代碼行數:8,代碼來源:IntegrationTest.php

示例9: getAll

 /**
  * @return Job[]
  */
 public function getAll()
 {
     $this->conn->connect();
     $stmt = $this->conn->query("select * from {$this->table_name}");
     $stmt->setFetchMode(\PDO::FETCH_CLASS, '\\ebussola\\job\\job\\Job');
     $stmt->execute();
     $jobs = $stmt->fetchAll();
     $this->conn->close();
     return $jobs;
 }
開發者ID:ebussola,項目名稱:job-schedule-se,代碼行數:13,代碼來源:Doctrine.php

示例10: close

 /**
  * close Doctrine Dbal and ORM connection and reset everything to default.
  */
 public function close()
 {
     $this->Conn->close();
     if (is_object($this->EntityManager) && method_exists($this->EntityManager, 'close')) {
         $this->EntityManager->close();
     }
     if (function_exists('gc_collect_cycles')) {
         gc_collect_cycles();
     }
     $this->Conn = '';
     $this->EntityManager = '';
     $this->table_prefix = '';
     $this->table_siteid_prefix = '';
 }
開發者ID:AgniCMS,項目名稱:agni-framework,代碼行數:17,代碼來源:Db.php

示例11: close

 /**
  * {@inheritDoc}
  */
 public function close($force = false)
 {
     if ($force) {
         parent::close();
         $this->unsetPersistedConnection();
     }
 }
開發者ID:ruslan-polutsygan,項目名稱:dev-bundle,代碼行數:10,代碼來源:PersistedConnection.php

示例12: logout

 /**
  * {@inheritDoc}
  */
 public function logout()
 {
     if ($this->loggedIn) {
         $this->loggedIn = false;
         $this->conn->close();
         $this->conn = null;
     }
 }
開發者ID:jackalope,項目名稱:jackalope-doctrine-dbal,代碼行數:11,代碼來源:Client.php

示例13: preTask

 public function preTask(Worker $worker, array $options = null)
 {
     if ($worker instanceof DoctrineAwareWorker) {
         if ($this->connection) {
             try {
                 $this->connection->executeQuery('SELECT 1');
             } catch (DBALException $e) {
                 if ($e->getPrevious()->getCode() == "HY000") {
                     $this->logger->info('Reconnecting doctrine', ['e' => $e]);
                     $this->connection->close();
                 } else {
                     throw $e;
                 }
             }
         }
     }
 }
開發者ID:mcfedr,項目名稱:job-manager-bundle,代碼行數:17,代碼來源:DoctrineListener.php

示例14: testHeartBeatException

 public function testHeartBeatException()
 {
     $this->setExpectedException('\\RuntimeException', 'Counld not connect to database');
     $this->getDatabaseTester()->getConnection();
     $config1 = new DoctrineConfig($this->connection);
     $this->assertEquals(0, $config1->getMachine());
     $this->connection->close();
     $config1->heartbeat();
 }
開發者ID:Gendoria,項目名稱:cruftflake,代碼行數:9,代碼來源:DoctrineConfigTest.php

示例15: initializeDatabase

 private static final function initializeDatabase()
 {
     if (!self::$dbReused) {
         self::runCommand('doctrine:database:drop', array('--force' => true));
         self::runCommand('doctrine:database:create');
         self::$conn->close();
         self::$conn->connect();
         foreach (self::$dbInitializer->getMigrationFiles() as $file) {
             self::runCommand('dbal:import', array('file' => $file));
         }
     }
 }
開發者ID:zyxist,項目名稱:cantiga,代碼行數:12,代碼來源:DatabaseTestCase.php


注:本文中的Doctrine\DBAL\Connection::close方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。