![]() |
Active Record + Multiple Databases + Models - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Active Record + Multiple Databases + Models (/showthread.php?tid=7140) |
Active Record + Multiple Databases + Models - El Forum - 03-26-2008 [eluser]lookatthosemoose[/eluser] Hiya everybody! Question in regards to Active Record / Multiple Databases and their use in Models. OK, so I've created 2 database connection groups in my DB config file. Next, I (successfully) connect to the DBs in a controller like such: Code: function Login() Later in my controller, I want to invoke the function of a model (using active record) like such: EDIT - I'm aware the model isn't loaded in the code above, that's part of the question Code: function process(){ "code" being the (active record) model where I want to run the query, like such: Code: class Code extends Model { Initially, I was auto-loading my models in my autoload.php, which now I see I cannot do when using multiple DBs because (I think) I have to pass in the DB info when the model is loaded, either using this from what I found in the Docs: Code: $this->load->model('code', '', TRUE); //autoload (I dont think this will work) OR Code: $config['hostname'] = "localhost"; So 2 main questions: 1 - How would I access one of the DB connections from within my models. 2 - Without having to use the 2nd option above of passing in the DB config array? I figure since it's already loaded as $CAMPAIGN and $MATRIX (above), I should be able to tell the model to use one of those. I hope this makes sense. Thanks! --Eric-- |