當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。