Doctrine\DBAL\Connection::ping PHP Method

ping() public method

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
return 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

コード例 #1
1
 /**
  * @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