/** * Make the connection to the database * * @param array $components Results of parse_url() * @throws Exception */ public function __construct($components) { parent::__construct($components); if ($this->persist && function_exists('mysql_pconnect')) { $this->connection = @mysql_pconnect($this->hostPort, $this->username, $this->password); } elseif (function_exists('mysql_connect')) { $this->connection = @mysql_connect($this->hostPort, $this->username, $this->password); } else { throw new Exception('PHP does not have MySQL functions enabled'); } if (false === $this->connection) { throw new Exception(mysql_error(), mysql_errno()); } }
/** * Make the connection to the database * * @param array $components Results of parse_url() * @throws Exception SQLite functions are not enabled * @throws Exception Error connecting to the database */ public function __construct($components) { parent::__construct($components); $mode = 0666; // default for sqlite_open and sqlite_popen parse_str($components['query'], $options); if (isset($options['mode'])) { $mode = $options['mode']; } if ($this->persist && function_exists('sqlite_popen')) { $this->connection = @sqlite_popen('/' . $this->db, $mode, $errorMessage); } elseif (function_exists('sqlite_open')) { $this->connection = @sqlite_open('/' . $this->db, $mode, $errorMessage); } else { throw new Exception('PHP does not have SQLite functions enabled'); } if (false === $this->connection) { throw new Exception($errorMessage); } }