How can I manage mutiple databases? |
Hi everybody!
I'm facing with manage 2 databases in my proyect, and I found a little help in the user-guide from ellislab https://ellislab.com/codeIgniter/user-gu...cting.html but I don't know where I must to set this: $DB1 = $this->load->database('group_one', TRUE); $DB2 = $this->load->database('group_two', TRUE); Is it into the config/database.php file? or in my models? I also found some threads at stackoverflow, but the solutions point to the old forum, and... well, it is not more aviable so... any help? thanks! PD English is not my mother language, I hope it will not be a issue! I can understand it really good, but with writting... I'm not soooo good
Yes, the documentation doesn't explain the entire process. It does tell you how to set up the two groups in config/database.php. You know that part. Now what you do is this.
In your model file, make it look like this PHP Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); Then, in your model functions, you do this PHP Code: public function get_records_1() In your controller, you don't have to do anything special. Just like normal. PHP Code: $records_1 = $this->some_model->get_records_1();
Hey, don't work without a PHP debugger. Several free IDEs have this features built in. Two are NetBeans and CodeLobster. Without a debugger, it's like you're driving with a blindfold on -- you are going to crash!
|
Welcome Guest, Not a member yet? Register Sign In |