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


PHP Connection::isConnected方法代码示例

本文整理汇总了PHP中Doctrine\DBAL\Connection::isConnected方法的典型用法代码示例。如果您正苦于以下问题:PHP Connection::isConnected方法的具体用法?PHP Connection::isConnected怎么用?PHP Connection::isConnected使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine\DBAL\Connection的用法示例。


在下文中一共展示了Connection::isConnected方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: connectDatabase

 private function connectDatabase(OutputInterface $output)
 {
     $param = array();
     $param['host'] = $this->dialog->ask($output, '<question>Where is your database server? [localhost]</question> ', 'localhost');
     $param['user'] = $this->dialog->ask($output, '<question>What is your database username? [root]</question> ', 'root');
     $param['password'] = $this->dialog->ask($output, '<question>What is your database password?</question> ', '');
     $param['driver'] = 'pdo_mysql';
     // Save dbName for later use to create database
     $this->dbName = $this->dialog->ask($output, '<question>What is your database name? [BungaWire]</question> ', 'BungaWire');
     $output->writeln('');
     // Write empty line for easy read
     $config = new Configuration();
     $this->dbConnection = DriverManager::getConnection($param, $config);
     $this->dbConnection->connect();
     if ($this->dbConnection->isConnected() === false) {
         $output->writeln('Database connection failed, please check your setting');
         $output->writeln('You connection configuration is:');
         $output->writeln('host: ' . $param['host']);
         $output->writeln('user: ' . $param['user']);
         $output->writeln('password: ' . $param['password']);
         $output->writeln('Database Name: ' . $param['dbname']);
         $output->writeln('Driver: ' . $param['driver']);
         $output->writeln($this->dbConnection->errorInfo());
         $output->writeln('Please try again!');
         $this->connectDatabase($output);
     } else {
         $output->writeln('Database connected!');
     }
 }
开发者ID:gusdecool,项目名称:bunga-wire,代码行数:29,代码来源:InstallRun.php

示例2: isConnected

 /**
  * Test if is connected
  *
  * @param bool $forceConnection
  * @return bool
  */
 public function isConnected($forceConnection = false)
 {
     if ($forceConnection) {
         $this->connection->connect();
     }
     return $this->connection->isConnected();
 }
开发者ID:sourcefabric,项目名称:newscoop,代码行数:13,代码来源:AdoDbAdapter.php

示例3: checkDatabase

 /**
  * @param Connection $connection
  *
  * @return bool
  */
 protected function checkDatabase(Connection $connection)
 {
     $result = false;
     try {
         $connection->connect();
         $result = $connection->isConnected() && $connection->getSchemaManager()->tablesExist([self::EVENT_TABLE_NAME]);
     } catch (\PDOException $e) {
     }
     return $result;
 }
开发者ID:Maksold,项目名称:platform,代码行数:15,代码来源:EventsCompilerPass.php

示例4: initConnection

 /**
  * Initialize the dbal connection lazily
  */
 private function initConnection()
 {
     if (true === $this->conn->isConnected() && true === $this->connectionInitialized) {
         return;
     }
     if ($this->conn->getDatabasePlatform() instanceof PostgreSqlPlatform) {
         $this->sequenceNodeName = 'phpcr_nodes_id_seq';
         $this->sequenceTypeName = 'phpcr_type_nodes_node_type_id_seq';
     }
     // @TODO: move to "SqlitePlatform" and rename to "registerExtraFunctions"?
     if ($this->conn->getDatabasePlatform() instanceof SqlitePlatform) {
         $this->registerSqliteFunctions($this->conn->getWrappedConnection());
     }
     $this->connectionInitialized = true;
 }
开发者ID:jackalope,项目名称:jackalope-doctrine-dbal,代码行数:18,代码来源:Client.php

示例5: unbufferConnection

 /**
  * Closes connection if open, opens a unbuffered connection.
  *
  * @param Connection $connection
  *
  * @throws InvalidArgumentException
  */
 public static function unbufferConnection(Connection $connection)
 {
     /** @var PDOConnection $wrappedConnection */
     $wrappedConnection = $connection->getWrappedConnection();
     if (!$wrappedConnection instanceof PDOConnection) {
         throw new InvalidArgumentException('unbufferConection can only be used with pdo_mysql Doctrine driver.');
     }
     if ($wrappedConnection->getAttribute(PDO::ATTR_DRIVER_NAME) != 'mysql') {
         throw new InvalidArgumentException('unbufferConection can only be used with PDO mysql driver, got "' . $wrappedConnection->getAttribute(PDO::ATTR_DRIVER_NAME) . '" instead.');
     }
     if ($connection->isConnected()) {
         $connection->close();
     }
     $connection->getWrappedConnection()->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false);
     $connection->connect();
 }
开发者ID:asev,项目名称:ConnectionsBundle,代码行数:23,代码来源:UnbufferedConnectionHelper.php

示例6: testIsConnected

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

示例7: connect

 /**
  * Stub method for connecting to the database
  *
  * Returns the result of
  * <code>Connection::isConnected()</code>
  *
  * @return bool
  */
 public function connect()
 {
     return $this->conn->isConnected();
 }
开发者ID:zenmagick,项目名称:zenmagick,代码行数:12,代码来源:QueryFactory.php

示例8: shutdown

 private function shutdown()
 {
     if ($this->connection !== null && $this->connection->isConnected()) {
         $this->connection->close();
     }
 }
开发者ID:MehrAlsNix,项目名称:cbtool,代码行数:6,代码来源:DBImportCommand.php

示例9: isConnectionEstablished

 /**
  * Determine, if the connection is established successful.
  *
  * @param \Doctrine\DBAL\Connection $connection The connection we want to know, if it is established.
  *
  * @return bool Is the connection successfully established?
  */
 protected function isConnectionEstablished($connection)
 {
     return $connection->isConnected();
 }
开发者ID:Alpha-Sys,项目名称:oxideshop_ce,代码行数:11,代码来源:Database.php

示例10: ensureConnected

 /**
  * Makes sure that the connection is open
  */
 protected function ensureConnected()
 {
     if (!$this->connection->isConnected()) {
         $this->connection->connect();
     }
 }
开发者ID:Maksold,项目名称:platform,代码行数:9,代码来源:MigrationEvent.php

示例11: isReady

 /**
  * Is the driver connected an ready to interact?
  *
  * @return bool
  */
 public function isReady()
 {
     return $this->connection && $this->connection->isConnected();
 }
开发者ID:mapbender,项目名称:data-source,代码行数:9,代码来源:DoctrineBaseDriver.php

示例12: testPassingExternalPDOMeansConnectionIsConnected

 public function testPassingExternalPDOMeansConnectionIsConnected()
 {
     $params['pdo'] = new \stdClass();
     $driverMock = $this->getMock('Doctrine\\DBAL\\Driver');
     $conn = new Connection($params, $driverMock);
     $this->assertTrue($conn->isConnected(), "Connection is not connected after passing external PDO");
 }
开发者ID:selimcr,项目名称:servigases,代码行数:7,代码来源:ConnectionTest.php


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