Doctrine\DBAL\Connection::ping PHP 메소드

ping() 공개 메소드

When the server is not available the method returns FALSE. It is responsibility of the developer to handle this case and abort the request or reconnect manually:
public ping ( ) : boolean
리턴 boolean
    public function ping()
    {
        $this->connect();
        if ($this->_conn instanceof PingableConnection) {
            return $this->_conn->ping();
        }
        try {
            $this->query($this->getDatabasePlatform()->getDummySelectSQL());
            return true;
        } catch (DBALException $e) {
            return false;
        }
    }

Usage Example

 /**
  * @return Connection
  */
 public function getConnection()
 {
     if (false === $this->connection->ping()) {
         $this->connection->close();
         $this->connection->connect();
     }
     return $this->connection;
 }
All Usage Examples Of Doctrine\DBAL\Connection::ping