summaryrefslogtreecommitdiffstats
path: root/system/database
diff options
context:
space:
mode:
Diffstat (limited to 'system/database')
-rw-r--r--system/database/DB_driver.php12
-rw-r--r--system/database/drivers/cubrid/cubrid_driver.php56
-rw-r--r--system/database/drivers/ibase/ibase_driver.php19
-rw-r--r--system/database/drivers/mssql/mssql_driver.php12
-rw-r--r--system/database/drivers/mysql/mysql_driver.php12
-rw-r--r--system/database/drivers/mysqli/mysqli_driver.php12
-rw-r--r--system/database/drivers/oci8/oci8_driver.php22
-rw-r--r--system/database/drivers/odbc/odbc_driver.php19
-rw-r--r--system/database/drivers/pdo/pdo_driver.php12
-rw-r--r--system/database/drivers/postgre/postgre_driver.php12
-rw-r--r--system/database/drivers/sqlite/sqlite_driver.php42
-rw-r--r--system/database/drivers/sqlite3/sqlite3_driver.php23
-rw-r--r--system/database/drivers/sqlsrv/sqlsrv_driver.php12
13 files changed, 51 insertions, 214 deletions
diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php
index aeeb2d0f3..7551e4896 100644
--- a/system/database/DB_driver.php
+++ b/system/database/DB_driver.php
@@ -435,6 +435,18 @@ abstract class CI_DB_driver {
// --------------------------------------------------------------------
/**
+ * Persistent database connection
+ *
+ * @return resource
+ */
+ public function db_pconnect()
+ {
+ return $this->db_connect(TRUE);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Reconnect
*
* Keep / reestablish the db connection if no queries have been
diff --git a/system/database/drivers/cubrid/cubrid_driver.php b/system/database/drivers/cubrid/cubrid_driver.php
index 0db51735c..2e79faa39 100644
--- a/system/database/drivers/cubrid/cubrid_driver.php
+++ b/system/database/drivers/cubrid/cubrid_driver.php
@@ -102,61 +102,23 @@ class CI_DB_cubrid_driver extends CI_DB {
/**
* Non-persistent database connection
*
- * @return resource
- */
- public function db_connect()
- {
- return $this->_cubrid_connect();
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Persistent database connection
- *
- * In CUBRID persistent DB connection is supported natively in CUBRID
- * engine which can be configured in the CUBRID Broker configuration
- * file by setting the CCI_PCONNECT parameter to ON. In that case, all
- * connections established between the client application and the
- * server will become persistent.
- *
- * @return resource
- */
- public function db_pconnect()
- {
- return $this->_cubrid_connect(TRUE);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * CUBRID connection
- *
- * A CUBRID-specific method to create a connection to the database.
- * Except for determining if a persistent connection should be used,
- * the rest of the logic is the same for db_connect() and db_pconnect().
- *
* @param bool $persistent
* @return resource
*/
- protected function _cubrid_connect($persistent = FALSE)
+ public function db_connect($persistent = FALSE)
{
if (preg_match('/^CUBRID:[^:]+(:[0-9][1-9]{0,4})?:[^:]+:([^:]*):([^:]*):(\?.+)?$/', $this->dsn, $matches))
{
- $_temp = ($persistent !== TRUE) ? 'cubrid_connect_with_url' : 'cubrid_pconnect_with_url';
- $conn_id = ($matches[2] === '' && $matches[3] === '' && $this->username !== '' && $this->password !== '')
- ? $_temp($this->dsn, $this->username, $this->password)
- : $_temp($this->dsn);
- }
- else
- {
- $_temp = ($persistent !== TRUE) ? 'cubrid_connect' : 'cubrid_pconnect';
- $conn_id = ($this->username !== '')
- ? $_temp($this->hostname, $this->port, $this->database, $this->username, $this->password)
- : $_temp($this->hostname, $this->port, $this->database);
+ $func = ($persistent !== TRUE) ? 'cubrid_connect_with_url' : 'cubrid_pconnect_with_url';
+ return ($matches[2] === '' && $matches[3] === '' && $this->username !== '' && $this->password !== '')
+ ? $func($this->dsn, $this->username, $this->password)
+ : $func($this->dsn);
}
- return $conn_id;
+ $func = ($persistent !== TRUE) ? 'cubrid_connect' : 'cubrid_pconnect';
+ return ($this->username !== '')
+ ? $func($this->hostname, $this->port, $this->database, $this->username, $this->password)
+ : $func($this->hostname, $this->port, $this->database);
}
// --------------------------------------------------------------------
diff --git a/system/database/drivers/ibase/ibase_driver.php b/system/database/drivers/ibase/ibase_driver.php
index 4cff5f448..c85b19955 100644
--- a/system/database/drivers/ibase/ibase_driver.php
+++ b/system/database/drivers/ibase/ibase_driver.php
@@ -69,23 +69,14 @@ class CI_DB_ibase_driver extends CI_DB {
/**
* Non-persistent database connection
*
+ * @param bool $persistent
* @return resource
*/
- public function db_connect()
+ public function db_connect($persistent = FALSE)
{
- return @ibase_connect($this->hostname.':'.$this->database, $this->username, $this->password, $this->char_set);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Persistent database connection
- *
- * @return resource
- */
- public function db_pconnect()
- {
- return @ibase_pconnect($this->hostname.':'.$this->database, $this->username, $this->password, $this->char_set);
+ return ($persistent === TRUE)
+ ? @ibase_pconnect($this->hostname.':'.$this->database, $this->username, $this->password, $this->char_set)
+ : @ibase_connect($this->hostname.':'.$this->database, $this->username, $this->password, $this->char_set);
}
// --------------------------------------------------------------------
diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php
index 9e53d4e6d..075542ae0 100644
--- a/system/database/drivers/mssql/mssql_driver.php
+++ b/system/database/drivers/mssql/mssql_driver.php
@@ -130,18 +130,6 @@ class CI_DB_mssql_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Persistent database connection
- *
- * @return resource
- */
- public function db_pconnect()
- {
- return $this->db_connect(TRUE);
- }
-
- // --------------------------------------------------------------------
-
- /**
* Select the database
*
* @param string $database
diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php
index 499d42691..9fbd94ce8 100644
--- a/system/database/drivers/mysql/mysql_driver.php
+++ b/system/database/drivers/mysql/mysql_driver.php
@@ -146,18 +146,6 @@ class CI_DB_mysql_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Persistent database connection
- *
- * @return resource
- */
- public function db_pconnect()
- {
- return $this->db_connect(TRUE);
- }
-
- // --------------------------------------------------------------------
-
- /**
* Reconnect
*
* Keep / reestablish the db connection if no queries have been
diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php
index 083b0c621..b2d0bcc87 100644
--- a/system/database/drivers/mysqli/mysqli_driver.php
+++ b/system/database/drivers/mysqli/mysqli_driver.php
@@ -114,18 +114,6 @@ class CI_DB_mysqli_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Persistent database connection
- *
- * @return object
- */
- public function db_pconnect()
- {
- return $this->db_connect(TRUE);
- }
-
- // --------------------------------------------------------------------
-
- /**
* Reconnect
*
* Keep / reestablish the db connection if no queries have been
diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php
index f309a8272..7453db7a8 100644
--- a/system/database/drivers/oci8/oci8_driver.php
+++ b/system/database/drivers/oci8/oci8_driver.php
@@ -208,27 +208,15 @@ class CI_DB_oci8_driver extends CI_DB {
/**
* Non-persistent database connection
*
+ * @param bool $persistent
* @return resource
*/
- public function db_connect()
- {
- return ( ! empty($this->char_set))
- ? @oci_connect($this->username, $this->password, $this->dsn, $this->char_set)
- : @oci_connect($this->username, $this->password, $this->dsn);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Persistent database connection
- *
- * @return resource
- */
- public function db_pconnect()
+ public function db_connect($persistent = FALSE)
{
+ $func = ($persistent === TRUE) ? 'oci_pconnect' : 'oci_connect';
return empty($this->char_set)
- ? @oci_pconnect($this->username, $this->password, $this->dsn)
- : @oci_pconnect($this->username, $this->password, $this->dsn, $this->char_set);
+ ? $func($this->username, $this->password, $this->dsn)
+ : $func($this->username, $this->password, $this->dsn, $this->char_set);
}
// --------------------------------------------------------------------
diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php
index 662a1063a..14c85c8e2 100644
--- a/system/database/drivers/odbc/odbc_driver.php
+++ b/system/database/drivers/odbc/odbc_driver.php
@@ -104,23 +104,14 @@ class CI_DB_odbc_driver extends CI_DB {
/**
* Non-persistent database connection
*
+ * @param bool $persistent
* @return resource
*/
- public function db_connect()
+ public function db_connect($persistent = FALSE)
{
- return @odbc_connect($this->dsn, $this->username, $this->password);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Persistent database connection
- *
- * @return resource
- */
- public function db_pconnect()
- {
- return @odbc_pconnect($this->dsn, $this->username, $this->password);
+ return ($persistent === TRUE)
+ ? odbc_pconnect($this->dsn, $this->username, $this->password)
+ : odbc_connect($this->dsn, $this->username, $this->password);
}
// --------------------------------------------------------------------
diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php
index 49612b972..01731489f 100644
--- a/system/database/drivers/pdo/pdo_driver.php
+++ b/system/database/drivers/pdo/pdo_driver.php
@@ -135,18 +135,6 @@ class CI_DB_pdo_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Persistent database connection
- *
- * @return object
- */
- public function db_pconnect()
- {
- return $this->db_connect(TRUE);
- }
-
- // --------------------------------------------------------------------
-
- /**
* Database version number
*
* @return string
diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php
index 7d17f799e..1140d501b 100644
--- a/system/database/drivers/postgre/postgre_driver.php
+++ b/system/database/drivers/postgre/postgre_driver.php
@@ -162,18 +162,6 @@ class CI_DB_postgre_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Persistent database connection
- *
- * @return resource
- */
- public function db_pconnect()
- {
- return $this->db_connect(TRUE);
- }
-
- // --------------------------------------------------------------------
-
- /**
* Reconnect
*
* Keep / reestablish the db connection if no queries have been
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;
}
diff --git a/system/database/drivers/sqlite3/sqlite3_driver.php b/system/database/drivers/sqlite3/sqlite3_driver.php
index 30c38ec47..a7d0d087d 100644
--- a/system/database/drivers/sqlite3/sqlite3_driver.php
+++ b/system/database/drivers/sqlite3/sqlite3_driver.php
@@ -63,10 +63,16 @@ class CI_DB_sqlite3_driver extends CI_DB {
/**
* Non-persistent database connection
*
- * @return object type SQLite3
+ * @param bool $persistent
+ * @return SQLite3
*/
- public function db_connect()
+ public function db_connect($persistent = FALSE)
{
+ if ($persistent)
+ {
+ log_message('debug', 'SQLite3 doesn\'t support persistent connections');
+ }
+
try
{
return ( ! $this->password)
@@ -82,19 +88,6 @@ class CI_DB_sqlite3_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Persistent database connection
- *
- * @return object type SQLite3
- */
- public function db_pconnect()
- {
- log_message('debug', 'SQLite3 doesn\'t support persistent connections');
- return $this->db_connect();
- }
-
- // --------------------------------------------------------------------
-
- /**
* Database version number
*
* @return string
diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php
index a723b78bc..58f2e3420 100644
--- a/system/database/drivers/sqlsrv/sqlsrv_driver.php
+++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php
@@ -144,18 +144,6 @@ class CI_DB_sqlsrv_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Persistent database connection
- *
- * @return resource
- */
- public function db_pconnect()
- {
- return $this->db_connect(TRUE);
- }
-
- // --------------------------------------------------------------------
-
- /**
* Select the database
*
* @param string $database