From 1a0014941dcf399e97d3586bd6d3382166b413dd Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 24 Jan 2013 11:32:29 +0200 Subject: 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. --- system/database/drivers/mysql/mysql_driver.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'system/database/drivers/mysql/mysql_driver.php') 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; } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b