src/Drivers/SQLite3Driver.php
public function connect() {
    // Check that the SQLite3 extension is installed.
    if (!class_exists('SQLite3')) {
      throw new Exceptions\UnableToConnectException(
          'SQLite3 PHP extension is not available. It probably has not '.
          'been installed. Please install and configure it in order to use '.
          'SQLite3.'
      );
    }
    $filename = $this->config['SQLite3']['filename'];
    $busyTimeout = $this->config['SQLite3']['busy_timeout'];
    $openFlags = $this->config['SQLite3']['open_flags'];
    $encryptionKey = $this->config['SQLite3']['encryption_key'];
    // Connecting
    if (!$this->connected) {
      $this->link = new SQLite3($filename, $openFlags, $encryptionKey);
      if ($this->link) {
        $this->connected = true;
        $this->link->busyTimeout($busyTimeout);
        // Set database and connection options.
        $this->link->exec("PRAGMA encoding = \"UTF-8\";");
        $this->link->exec("PRAGMA foreign_keys = 1;");
        $this->link->exec("PRAGMA case_sensitive_like = 1;");
        // Create the preg_match and regexp functions.
        // TODO(hperrin): Add more of these functions to get rid of post-query checks.
        $this->link->createFunction('preg_match', 'preg_match', 2, SQLITE3_DETERMINISTIC);
        $this->link->createFunction('regexp', function ($pattern, $subject) {
          return !!$this->posixRegexMatch($pattern, $subject);
        }, 2, SQLITE3_DETERMINISTIC);
      } else {
        $this->connected = false;
        if ($filename === ':memory:') {
          throw new Exceptions\NotConfiguredException();
        } else {
          throw new Exceptions\UnableToConnectException('Could not connect.');
        }
      }
    }
    return $this->connected;
  }
public function connect() {
    // Check that the SQLite3 extension is installed.
    if (!class_exists('SQLite3')) {
      throw new Exceptions\UnableToConnectException(
          'SQLite3 PHP extension is not available. It probably has not '.
          'been installed. Please install and configure it in order to use '.
          'SQLite3.'
      );
    }
    $filename = $this->config['SQLite3']['filename'];
    $busyTimeout = $this->config['SQLite3']['busy_timeout'];
    $openFlags = $this->config['SQLite3']['open_flags'];
    $encryptionKey = $this->config['SQLite3']['encryption_key'];
    // Connecting
    if (!$this->connected) {
      $this->link = new SQLite3($filename, $openFlags, $encryptionKey);
      if ($this->link) {
        $this->connected = true;
        $this->link->busyTimeout($busyTimeout);
        // Set database and connection options.
        $this->link->exec("PRAGMA encoding = \"UTF-8\";");
        $this->link->exec("PRAGMA foreign_keys = 1;");
        $this->link->exec("PRAGMA case_sensitive_like = 1;");
        // Create the preg_match and regexp functions.
        // TODO(hperrin): Add more of these functions to get rid of post-query checks.
        $this->link->createFunction('preg_match', 'preg_match', 2, SQLITE3_DETERMINISTIC);
        $this->link->createFunction('regexp', function ($pattern, $subject) {
          return !!$this->posixRegexMatch($pattern, $subject);
        }, 2, SQLITE3_DETERMINISTIC);
      } else {
        $this->connected = false;
        if ($filename === ':memory:') {
          throw new Exceptions\NotConfiguredException();
        } else {
          throw new Exceptions\UnableToConnectException('Could not connect.');
        }
      }
    }
    return $this->connected;
  }
public function connect ( ) { // Check that the SQLite3 extension is installed. if ( ! class_exists ( 'SQLite3' ) ) { throw new Exceptions \ UnableToConnectException ( 'SQLite3 PHP extension is not available. It probably has not ' . 'been installed. Please install and configure it in order to use ' . 'SQLite3.' ) ; } $ filename = $ this -> config [ 'SQLite3' ] [ 'filename' ] ; $ busyTimeout = $ this -> config [ 'SQLite3' ] [ 'busy_timeout' ] ; $ openFlags = $ this -> config [ 'SQLite3' ] [ 'open_flags' ] ; $ encryptionKey = $ this -> config [ 'SQLite3' ] [ 'encryption_key' ] ; // Connecting if ( ! $ this -> connected ) { $ this -> link = new SQLite3 ( $ filename , $ openFlags , $ encryptionKey ) ; if ( $ this -> link ) { $ this -> connected = true ; $ this -> link -> busyTimeout ( $ busyTimeout ) ; // Set database and connection options. $ this -> link -> exec ( "PRAGMA encoding = \"UTF-8\";" ) ; $ this -> link -> exec ( "PRAGMA foreign_keys = 1;" ) ; $ this -> link -> exec ( "PRAGMA case_sensitive_like = 1;" ) ; // Create the preg_match and regexp functions. // TODO(hperrin): Add more of these functions to get rid of post-query checks. $ this -> link -> createFunction ( 'preg_match' , 'preg_match' , 2 , SQLITE3_DETERMINISTIC ) ; $ this -> link -> createFunction ( 'regexp' , function ( $ pattern , $ subject ) { return ! ! $ this -> posixRegexMatch ( $ pattern , $ subject ) ; } , 2 , SQLITE3_DETERMINISTIC ) ; } else { $ this -> connected = false ; if ( $ filename === ':memory:' ) { throw new Exceptions \ NotConfiguredException ( ) ; } else { throw new Exceptions \ UnableToConnectException ( 'Could not connect.' ) ; } } } return $ this -> connected ; }
Connect to the SQLite3 database.

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