Add an optional database name parameter to db_select()
diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php
index 2a10989..27b492f 100644
--- a/system/database/drivers/mssql/mssql_driver.php
+++ b/system/database/drivers/mssql/mssql_driver.php
@@ -114,14 +114,14 @@
/**
* Select the database
*
- * @access private called by the base class
- * @return resource
+ * @param string database name
+ * @return bool
*/
- function db_select()
+ public function db_select($database = '')
{
// Note: The brackets are required in the event that the DB name
// contains reserved characters
- return @mssql_select_db('['.$this->database.']', $this->conn_id);
+ return @mssql_select_db('['.($database == '' ? $this->database : $database).']', $this->conn_id);
}
// --------------------------------------------------------------------
@@ -676,4 +676,4 @@
/* End of file mssql_driver.php */
-/* Location: ./system/database/drivers/mssql/mssql_driver.php */
\ No newline at end of file
+/* Location: ./system/database/drivers/mssql/mssql_driver.php */
diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php
index 067710f..207a68f 100644
--- a/system/database/drivers/mysql/mysql_driver.php
+++ b/system/database/drivers/mysql/mysql_driver.php
@@ -119,11 +119,12 @@
/**
* Select the database
*
+ * @param string database name
* @return bool
*/
- public function db_select()
+ public function db_select($database = '')
{
- return @mysql_select_db($this->database, $this->conn_id);
+ return @mysql_select_db(($database == '' ? $this->database : $database), $this->conn_id);
}
// --------------------------------------------------------------------
diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php
index a79b2a4..0b80f55 100644
--- a/system/database/drivers/mysqli/mysqli_driver.php
+++ b/system/database/drivers/mysqli/mysqli_driver.php
@@ -119,11 +119,12 @@
/**
* Select the database
*
+ * @param string database name
* @return bool
*/
- public function db_select()
+ public function db_select($database = '')
{
- return @mysqli_select_db($this->conn_id, $this->database);
+ return @mysqli_select_db($this->conn_id, ($database == '' ? $this->database : $database));
}
// --------------------------------------------------------------------
diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php
index 6fd52ef..3908400 100644
--- a/system/database/drivers/sqlsrv/sqlsrv_driver.php
+++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php
@@ -122,12 +122,12 @@
/**
* Select the database
*
- * @access private called by the base class
- * @return resource
+ * @param string database name
+ * @return bool
*/
- function db_select()
+ public function db_select($database = '')
{
- return $this->_execute('USE ' . $this->database);
+ return $this->_execute('USE '.($database == '' ? $this->database : $database));
}
// --------------------------------------------------------------------
@@ -608,4 +608,4 @@
/* End of file mssql_driver.php */
-/* Location: ./system/database/drivers/mssql/mssql_driver.php */
\ No newline at end of file
+/* Location: ./system/database/drivers/mssql/mssql_driver.php */