01-22-2009, 09:17 AM
[eluser]louis w[/eluser]
I have two databases set in my database config. One as ['default'], which is the one I will primarily be using. On a rare occasion I will need to connect to another one.
Inside my model I perform my normal db queries (on the default database) and then if I need to connect to the other one I load it this way:
$db_teaser = $this->CI->load->database('db_teaser', TRUE);
However the problem arises that if later on in my model I want to query the default database again (e.g. $this->db->simple_query), it doesn't work. It's trying to connect to the second database loaded.
Is there a way for $this->db to always query the default database and the second one to work with $db_teaser?
Problem with loading the default database not as $this->db is that when I dont have two databases loaded I would still have to reference it like this.
Thanks. Hope this is clear.
I have two databases set in my database config. One as ['default'], which is the one I will primarily be using. On a rare occasion I will need to connect to another one.
Inside my model I perform my normal db queries (on the default database) and then if I need to connect to the other one I load it this way:
$db_teaser = $this->CI->load->database('db_teaser', TRUE);
However the problem arises that if later on in my model I want to query the default database again (e.g. $this->db->simple_query), it doesn't work. It's trying to connect to the second database loaded.
Is there a way for $this->db to always query the default database and the second one to work with $db_teaser?
Problem with loading the default database not as $this->db is that when I dont have two databases loaded I would still have to reference it like this.
Thanks. Hope this is clear.