diff options
author | Andrey Andreev <narf@bofh.bg> | 2013-01-24 10:32:29 +0100 |
---|---|---|
committer | Andrey Andreev <narf@bofh.bg> | 2013-01-24 10:32:29 +0100 |
commit | 1a0014941dcf399e97d3586bd6d3382166b413dd (patch) | |
tree | 03d903de3f126bf68ecfbb3d031dafe42981cdb6 /system/database/drivers | |
parent | de5744f78c44c417f41ae01eb59488a63adabd7f (diff) |
Move db_select() call from CI_DB_driver::initialize() to db_connect()
so that it's only called by drivers that need it ('mysql', 'mssql').
As proposed in issue #2187.
Diffstat (limited to 'system/database/drivers')
-rw-r--r-- | system/database/drivers/mssql/mssql_driver.php | 12 | ||||
-rw-r--r-- | system/database/drivers/mysql/mysql_driver.php | 16 |
2 files changed, 27 insertions, 1 deletions
diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php index f60071ed9..0836fa802 100644 --- a/system/database/drivers/mssql/mssql_driver.php +++ b/system/database/drivers/mssql/mssql_driver.php @@ -106,6 +106,18 @@ class CI_DB_mssql_driver extends CI_DB { return FALSE; } + // ---------------------------------------------------------------- + + // Select the DB... assuming a database name is specified in the config file + if ($this->database !== '' && ! $this->db_select()) + { + log_message('error', 'Unable to select database: '.$this->database); + + return ($this->db_debug === TRUE) + ? $this->display_error('db_unable_to_select', $this->database) + : FALSE; + } + // Determine how identifiers are escaped $query = $this->query('SELECT CASE WHEN (@@OPTIONS | 256) = @@OPTIONS THEN 1 ELSE 0 END AS qi'); $query = $query->row_array(); diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php index 492b07861..95003f648 100644 --- a/system/database/drivers/mysql/mysql_driver.php +++ b/system/database/drivers/mysql/mysql_driver.php @@ -110,9 +110,23 @@ class CI_DB_mysql_driver extends CI_DB { $client_flags = $client_flags | MYSQL_CLIENT_SSL; } - return ($persistent === TRUE) + $this->conn_id = ($persistent === TRUE) ? @mysql_pconnect($this->hostname, $this->username, $this->password, $client_flags) : @mysql_connect($this->hostname, $this->username, $this->password, TRUE, $client_flags); + + // ---------------------------------------------------------------- + + // Select the DB... assuming a database name is specified in the config file + if ($this->database !== '' && ! $this->db_select()) + { + log_message('error', 'Unable to select database: '.$this->database); + + return ($this->db_debug === TRUE) + ? $this->display_error('db_unable_to_select', $this->database) + : FALSE; + } + + return $this->conn_id; } // -------------------------------------------------------------------- |