src/Drivers/MySQLDriver.php
public function connect() {
    // Check that the MySQLi extension is installed.
    if (!is_callable('mysqli_connect')) {
      throw new Exceptions\UnableToConnectException(
          'MySQLi PHP extension is not available. It probably has not been '.
          'installed. Please install and configure it in order to use MySQL.'
      );
    }
    $host = $this->config['MySQL']['host'];
    $user = $this->config['MySQL']['user'];
    $password = $this->config['MySQL']['password'];
    $database = $this->config['MySQL']['database'];
    $port = $this->config['MySQL']['port'];

    // If we think we're connected, try pinging the server.
    if ($this->connected && !mysqli_ping($this->link)) {
      $this->connected = false;
    }

    // Connecting, selecting database
    if (!$this->connected) {
      $link = is_callable($this->config['MySQL']['link'])
        ? $this->config['MySQL']['link']()
        : null;

      if ($this->link = $link ??
          mysqli_connect(
              $host,
              $user,
              $password,
              $database,
              $port
          )) {
        $this->connected = true;
      } else {
        $this->connected = false;
        if ($host === 'localhost'
            && $user === 'nymph'
            && $password === 'password'
            && $database === 'nymph'
            && $link === null) {
          throw new Exceptions\NotConfiguredException();
        } else {
          throw new Exceptions\UnableToConnectException(
              'Could not connect: '.
                  mysqli_error($this->link)
          );
        }
      }
    }
    return $this->connected;
  }
public function connect() {
    // Check that the MySQLi extension is installed.
    if (!is_callable('mysqli_connect')) {
      throw new Exceptions\UnableToConnectException(
          'MySQLi PHP extension is not available. It probably has not been '.
          'installed. Please install and configure it in order to use MySQL.'
      );
    }
    $host = $this->config['MySQL']['host'];
    $user = $this->config['MySQL']['user'];
    $password = $this->config['MySQL']['password'];
    $database = $this->config['MySQL']['database'];
    $port = $this->config['MySQL']['port'];

    // If we think we're connected, try pinging the server.
    if ($this->connected && !mysqli_ping($this->link)) {
      $this->connected = false;
    }

    // Connecting, selecting database
    if (!$this->connected) {
      $link = is_callable($this->config['MySQL']['link'])
        ? $this->config['MySQL']['link']()
        : null;

      if ($this->link = $link ??
          mysqli_connect(
              $host,
              $user,
              $password,
              $database,
              $port
          )) {
        $this->connected = true;
      } else {
        $this->connected = false;
        if ($host === 'localhost'
            && $user === 'nymph'
            && $password === 'password'
            && $database === 'nymph'
            && $link === null) {
          throw new Exceptions\NotConfiguredException();
        } else {
          throw new Exceptions\UnableToConnectException(
              'Could not connect: '.
                  mysqli_error($this->link)
          );
        }
      }
    }
    return $this->connected;
  }
public function connect ( ) { // Check that the MySQLi extension is installed. if ( ! is_callable ( 'mysqli_connect' ) ) { throw new Exceptions \ UnableToConnectException ( 'MySQLi PHP extension is not available. It probably has not been ' . 'installed. Please install and configure it in order to use MySQL.' ) ; } $ host = $ this -> config [ 'MySQL' ] [ 'host' ] ; $ user = $ this -> config [ 'MySQL' ] [ 'user' ] ; $ password = $ this -> config [ 'MySQL' ] [ 'password' ] ; $ database = $ this -> config [ 'MySQL' ] [ 'database' ] ; $ port = $ this -> config [ 'MySQL' ] [ 'port' ] ; // If we think we're connected, try pinging the server. if ( $ this -> connected && ! mysqli_ping ( $ this -> link ) ) { $ this -> connected = false ; } // Connecting, selecting database if ( ! $ this -> connected ) { $ link = is_callable ( $ this -> config [ 'MySQL' ] [ 'link' ] ) ? $ this -> config [ 'MySQL' ] [ 'link' ] ( ) : null ; if ( $ this -> link = $ link ?? mysqli_connect ( $ host , $ user , $ password , $ database , $ port ) ) { $ this -> connected = true ; } else { $ this -> connected = false ; if ( $ host === 'localhost' && $ user === 'nymph' && $ password === 'password' && $ database === 'nymph' && $ link === null ) { throw new Exceptions \ NotConfiguredException ( ) ; } else { throw new Exceptions \ UnableToConnectException ( 'Could not connect: ' . mysqli_error ( $ this -> link ) ) ; } } } return $ this -> connected ; }
Connect to the MySQL database.

@return bool Whether this instance is connected to a MySQL database after
the method has run.
Connect to the MySQL database .