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