src/Model/Adapter/PDO/PDOAdapter.php
private function reconnect()
    {
        if (0 === (int) $this->getOption(self::OPT_MAX_RECONNECT_ATTEMPTS)) {
            throw new MaxConnectAttempsException("Connection lost.");
        } elseif ($this->reconnectAttempts === (int) $this->getOption(self::OPT_MAX_RECONNECT_ATTEMPTS)) {
            throw new MaxConnectAttempsException("Max attempts to connect to database has been reached.");
        }

        if (null === $this->credentials) {
            throw new AccessDeniedException("Unable to reconnect: credentials not provided.");
        }

        try {
            if (0 !== $this->reconnectAttempts) {
                usleep((int) $this->getOption(self::OPT_USLEEP_AFTER_FIRST_ATTEMPT));
            }
            $this->cnx = self::createLink($this->getCredentials(), $this->options);
            if ($this->isConnected()) {
                $this->reconnectAttempts = 0;
            } else {
                $this->reconnect();
            }
        } catch (Throwable $e) {
            $this->reconnectAttempts++;
        }
    }
private function reconnect()
    {
        if (0 === (int) $this->getOption(self::OPT_MAX_RECONNECT_ATTEMPTS)) {
            throw new MaxConnectAttempsException("Connection lost.");
        } elseif ($this->reconnectAttempts === (int) $this->getOption(self::OPT_MAX_RECONNECT_ATTEMPTS)) {
            throw new MaxConnectAttempsException("Max attempts to connect to database has been reached.");
        }

        if (null === $this->credentials) {
            throw new AccessDeniedException("Unable to reconnect: credentials not provided.");
        }

        try {
            if (0 !== $this->reconnectAttempts) {
                usleep((int) $this->getOption(self::OPT_USLEEP_AFTER_FIRST_ATTEMPT));
            }
            $this->cnx = self::createLink($this->getCredentials(), $this->options);
            if ($this->isConnected()) {
                $this->reconnectAttempts = 0;
            } else {
                $this->reconnect();
            }
        } catch (Throwable $e) {
            $this->reconnectAttempts++;
        }
    }
private function reconnect ( ) { if ( 0 === ( int ) $ this -> getOption ( self :: OPT_MAX_RECONNECT_ATTEMPTS ) ) { throw new MaxConnectAttempsException ( "Connection lost." ) ; } elseif ( $ this -> reconnectAttempts === ( int ) $ this -> getOption ( self :: OPT_MAX_RECONNECT_ATTEMPTS ) ) { throw new MaxConnectAttempsException ( "Max attempts to connect to database has been reached." ) ; } if ( null === $ this -> credentials ) { throw new AccessDeniedException ( "Unable to reconnect: credentials not provided." ) ; } try { if ( 0 !== $ this -> reconnectAttempts ) { usleep ( ( int ) $ this -> getOption ( self :: OPT_USLEEP_AFTER_FIRST_ATTEMPT ) ) ; } $ this -> cnx = self :: createLink ( $ this -> getCredentials ( ) , $ this -> options ) ; if ( $ this -> isConnected ( ) ) { $ this -> reconnectAttempts = 0 ; } else { $ this -> reconnect ( ) ; } } catch ( Throwable $ e ) { $ this -> reconnectAttempts ++ ; } }
Tries to reconnect to database.
Tries to reconnect to database .