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


PHP Connection::ping方法代码示例

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


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

示例1: 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

示例2: checkStandardConnection

 /**
  * @param Connection $connection
  * @return Success|Failure
  */
 private function checkStandardConnection(Connection $connection)
 {
     if ($connection->ping()) {
         return new Success(get_class($connection));
     }
     return new Failure(get_class($connection));
 }
开发者ID:abacaphiliac,项目名称:doctrine-orm-diagnostics-module,代码行数:11,代码来源:CheckConnection.php

示例3: pingIt

 protected function pingIt(Connection $con)
 {
     if ($con->ping() === false) {
         $con->close();
         $con->connect();
     }
     return $con;
 }
开发者ID:arnulfojr,项目名称:qcharts,代码行数:8,代码来源:DynamicEntityManager.php

示例4: 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

示例5: attemptToReconnectPresumedLostConnection

 /**
  * It attempts to reconnect if connection is non responsive. Failing to reconnect triggers a critical error.
  * If connection is responsive or successfully reconnected it rethrows, relying on the bus retries
  * to re-execute everything from the beginning.
  *
  * @param \Exception $e
  *
  * @return \Exception|CriticalErrorException
  */
 private function attemptToReconnectPresumedLostConnection(\Exception $e)
 {
     // presumably, any exception caught here is related to some connection error
     if (!$this->connection->ping()) {
         // if pinging fails, we try to reconnect
         try {
             $this->connection->close();
             $this->connection->connect();
         } catch (\Exception $e) {
             // if reconnecting fails, there is no way that the bus can continue to function
             return new CriticalErrorException("Database connection failed.", 0, $e);
         }
     }
     return $e;
 }
开发者ID:phpservicebus,项目名称:persistence-doctrine2,代码行数:24,代码来源:OutboxPersister.php

示例6: keepalive

 private function keepalive(Connection $db)
 {
     if (false === $db->ping()) {
         $db->close();
         $db->connect();
     }
 }
开发者ID:webfactory,项目名称:slimdump,代码行数:7,代码来源:Dumper.php


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