本文整理匯總了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();
}
示例2: getConnection
/**
* @return Connection
*/
public function getConnection()
{
if (false === $this->connection->ping()) {
$this->connection->close();
$this->connection->connect();
}
return $this->connection;
}
示例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();
}
示例4: pingIt
protected function pingIt(Connection $con)
{
if ($con->ping() === false) {
$con->close();
$con->connect();
}
return $con;
}
示例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;
}
示例6: resetSharedConn
protected function resetSharedConn()
{
if (self::$_sharedConn) {
self::$_sharedConn->close();
self::$_sharedConn = null;
}
}
示例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();
}
}
示例8: tearDown
public function tearDown()
{
$this->connection->close();
$this->eventStore = null;
$this->eventNameResolver = null;
$this->serializer = null;
$this->connection = null;
}
示例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;
}
示例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 = '';
}
示例11: close
/**
* {@inheritDoc}
*/
public function close($force = false)
{
if ($force) {
parent::close();
$this->unsetPersistedConnection();
}
}
示例12: logout
/**
* {@inheritDoc}
*/
public function logout()
{
if ($this->loggedIn) {
$this->loggedIn = false;
$this->conn->close();
$this->conn = null;
}
}
示例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;
}
}
}
}
}
示例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();
}
示例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));
}
}
}