Skip to content

Commit aa3e1b2

Browse files
committed
Stripping out the set_database stuff. It's causing problems, is difficult to test and isn't used very often.
1 parent 7ae2cd2 commit aa3e1b2

File tree

1 file changed

+3
-37
lines changed

1 file changed

+3
-37
lines changed

core/MY_Model.php

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,11 @@ class MY_Model extends CI_Model
1919
* guessed by pluralising the model name.
2020
*/
2121
protected $_table;
22-
23-
/**
24-
* Specify a database group to manually connect this model
25-
* to the specified DB. You can pass either the group name
26-
* as defined in application/config/database.php, or a
27-
* config array of the same format (basically the same thing
28-
* you can pass to $this->load->database()). If left empty,
29-
* the default DB will be used.
30-
*/
31-
protected $_db_group;
3222

3323
/**
3424
* The database connection object. Will be set to the default
35-
* connection unless $this->_db_group is specified. This allows
36-
* individual models to use different DBs without overwriting
37-
* CI's global $this->db connection.
25+
* connection. This allows individual models to use different DBs
26+
* without overwriting CI's global $this->db connection.
3827
*/
3928
public $_database;
4029

@@ -114,8 +103,8 @@ public function __construct()
114103

115104
$this->load->helper('inflector');
116105

117-
$this->_set_database();
118106
$this->_fetch_table();
107+
$this->_database = $this->db;
119108

120109
array_unshift($this->before_create, 'protect_attributes');
121110
array_unshift($this->before_update, 'protect_attributes');
@@ -878,29 +867,6 @@ private function _fetch_table()
878867
}
879868
}
880869

881-
/**
882-
* Establish the database connection.
883-
*/
884-
private function _set_database()
885-
{
886-
// Was a DB group specified by the user?
887-
if ($this->_db_group !== NULL)
888-
{
889-
$this->_database = $this->load->database($this->_db_group, TRUE, TRUE);
890-
}
891-
// No DB group specified, use the default connection.
892-
else
893-
{
894-
// Has the default connection been loaded yet?
895-
if ( ! isset($this->db) OR ! is_object($this->db))
896-
{
897-
$this->load->database('', FALSE, TRUE);
898-
}
899-
900-
$this->_database = $this->db;
901-
}
902-
}
903-
904870
/**
905871
* Set WHERE parameters, cleverly
906872
*/

0 commit comments

Comments
 (0)