Quantcast
Channel: CodeIgniter Forums - All Forums
Viewing all articles
Browse latest Browse all 14114

Separate DB connection for single model

$
0
0
I need a separate DB connection for single model. At the beggining i thought that it can be solved by loading model via:
Code:
$this->CI->load->model('some_model','','db_configuration_name');

but it is switching db connection for whole application, so any db call after that (also in other models loaded later) uses this connection.

Making change in constructor of model like this:
Code:
$this->db2 = $this->load->database('db_configuration_name',TRUE);
and using then only $this->db2 in this model id the only solution ?

Viewing all articles
Browse latest Browse all 14114


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>