From 2e171023bae38735ec08bbd9cb160cee75edbc62 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 25 Feb 2014 15:21:41 +0200 Subject: Make db_pconnect an alias for db_connect(TRUE) and reduce code repetition --- system/database/drivers/sqlite/sqlite_driver.php | 42 ++++-------------------- 1 file changed, 7 insertions(+), 35 deletions(-) (limited to 'system/database/drivers/sqlite') diff --git a/system/database/drivers/sqlite/sqlite_driver.php b/system/database/drivers/sqlite/sqlite_driver.php index 9928aedb7..dd9e1e849 100644 --- a/system/database/drivers/sqlite/sqlite_driver.php +++ b/system/database/drivers/sqlite/sqlite_driver.php @@ -62,45 +62,17 @@ class CI_DB_sqlite_driver extends CI_DB { /** * Non-persistent database connection * + * @param bool $persistent * @return resource */ - public function db_connect() + public function db_connect($persistent = FALSE) { - if ( ! $conn_id = @sqlite_open($this->database, FILE_WRITE_MODE, $error)) - { - log_message('error', $error); - - if ($this->db_debug) - { - $this->display_error($error, '', TRUE); - } - - return FALSE; - } - - return $conn_id; - } - - // -------------------------------------------------------------------- + $error = NULL; + $conn_id = ($persistent === TRUE) + ? sqlite_popen($this->database, 0666, $error) + : sqlite_open($this->database, 0666, $error); - /** - * Persistent database connection - * - * @return resource - */ - public function db_pconnect() - { - if ( ! $conn_id = @sqlite_popen($this->database, FILE_WRITE_MODE, $error)) - { - log_message('error', $error); - - if ($this->db_debug) - { - $this->display_error($error, '', TRUE); - } - - return FALSE; - } + isset($error) && log_message('error', $error); return $conn_id; } -- cgit v1.2.3-24-g4f1b