Welcome Guest, Not a member yet? Register   Sign In
Multiple Database Connections
#4

[eluser]helmutbjorg[/eluser]
Thanks for the quick response! Can you give me an example of how you would do that?

Code:
class Example extends Model {

      function Example() {
           parent::Model();
      }

}

I didn't think I could load it because the model uses another database connection that is defined inside a database.

For example...

Code:
$this->load->model('account');
// The table of accounts is on DATABASE #1
$account = $this->account->find(7);
// The table of groups is on DATABASE #2 (which is owned by the account above)
$this->load->model('group', '', array('hostname'=>$account->db_host, 'username'=>$account->db_user, etc));
$group = $this->group->find(7);
$group->name = 'Hello';
$group->save();
// And then I still want to be able to use DATABASE #1
$this->account->find(8);
// And also the session
$this->session->userdata('testing');

But it doesn't seem to be working... The group model defaults to the first database connection even with the parameter specified.


Messages In This Thread
Multiple Database Connections - by El Forum - 04-23-2009, 08:18 AM
Multiple Database Connections - by El Forum - 04-23-2009, 08:32 AM
Multiple Database Connections - by El Forum - 04-23-2009, 08:43 AM
Multiple Database Connections - by El Forum - 04-23-2009, 09:10 AM
Multiple Database Connections - by El Forum - 04-23-2009, 02:32 PM
Multiple Database Connections - by El Forum - 04-24-2009, 12:24 AM
Multiple Database Connections - by El Forum - 04-24-2009, 12:47 AM
Multiple Database Connections - by El Forum - 04-26-2009, 02:49 AM
Multiple Database Connections - by El Forum - 04-26-2009, 03:35 AM
Multiple Database Connections - by El Forum - 04-26-2009, 04:47 AM



Theme © iAndrew 2016 - Forum software by © MyBB