public function connect() {
    // Check that the PostgreSQL extension is installed.
    if (!is_callable('pg_connect')) {
      throw new Exceptions\UnableToConnectException(
          'PostgreSQL PHP extension is not available. It probably has not '.
          'been installed. Please install and configure it in order to use '.
          'PostgreSQL.'
      );
    }
    $connectionType = $this->config['PostgreSQL']['connection_type'];
    $host = $this->config['PostgreSQL']['host'];
    $port = $this->config['PostgreSQL']['port'];
    $user = $this->config['PostgreSQL']['user'];
    $password = $this->config['PostgreSQL']['password'];
    $database = $this->config['PostgreSQL']['database'];
    // Connecting, selecting database
    if (!$this->connected) {
      if ($connectionType === 'host') {
        $connectString = 'host=\''.addslashes($host).
            '\' port=\''.addslashes($port).
            '\' dbname=\''.addslashes($database).
            '\' user=\''.addslashes($user).
            '\' password=\''.addslashes($password).
            '\' connect_timeout=5';
      } else {
        $connectString = 'dbname=\''.addslashes($database).
            '\' user=\''.addslashes($user).
            '\' password=\''.addslashes($password).
            '\' connect_timeout=5';
      }
      if ($this->config['PostgreSQL']['allow_persistent']) {
        $this->link = pg_connect(
            $connectString.
                ' options=\'-c enable_hashjoin=off -c enable_mergejoin=off\''
        );
      } else {
        $this->link = pg_connect(
            $connectString.
                ' options=\'-c enable_hashjoin=off -c enable_mergejoin=off\'',
            PGSQL_CONNECT_FORCE_NEW
        );
        // Don't think this is necessary, but if put in options, will guarantee
        // connection is new. " -c timezone='.round(rand(10001000, 10009999)).'"
      }
      if ($this->link) {
        $this->connected = true;
      } else {
        $this->connected = false;
        if ($host === 'localhost'
            && $user === 'nymph'
            && $password === 'password'
            && $database === 'nymph'
            && $connectionType === 'host') {
          throw new Exceptions\NotConfiguredException();
        } else {
          throw new Exceptions\UnableToConnectException(
              'Could not connect: '.
                  pg_last_error()
          );
        }
      }
    }
    return $this->connected;
  }