For every project that I made, I always load database configuration in my construct function as below
public function __construct() {
parent::__construct();
$this->load->database();
}
For some reason, I want to load different configuration for every function inside one model as below
class Something_model extends CI_Model {
public function __construct() {
parent::__construct();
}
public function getAll() {
$this->load->database('DB1', TRUE);
// some code to be executed
}
public function getPart() {
$this->load->database('DB2', TRUE);
// some code to be executed
}
}
I need some advice about those new way loading database configuration. Is there any performance problem when I load the database in every function? Or is it safe to use?
Plus, is there any suggestion to call different database for different function inside one model?