Welcome Guest, Not a member yet? Register   Sign In
Active Record & Multiple Databases
#1

[eluser]Spicer[/eluser]
So I understand you can connect to more then one database doing something like this.
Code:
$DB1 = $this->load->database('group_one', TRUE);
$DB2 = $this->load->database('group_two', TRUE);

My problem is I have written a pretty big application using active record and one (default) database connection. So all my quires look like this.

Code:
$this->db->query();
$this->db->result();

It has come to my attention I need to move half of the database to another database. So I need two connections. So my quires should look something like this.

Code:
$DB1->query();
$DB1->result();
$DB2->query();
$DB2->result();

Now, I know I can do a search and replace and I will if I must, but is there a way to keep the current 'default' database be $this->db and add a second or third connection. So something like this.

Code:
$this->db->query();
$this->db->result();
$data1 = $this->db->result();

$DB->qurey();
$DB->result();
$data2 = $DB->result();

Every time I load the second database connection and assign it to $DB I lose the connection on $this->db.

Sorry this might be a dumb question but the inter-workings of the database class is something I do not understand all that well in CI.


Messages In This Thread
Active Record & Multiple Databases - by El Forum - 11-23-2009, 07:31 PM
Active Record & Multiple Databases - by El Forum - 11-23-2009, 09:49 PM
Active Record & Multiple Databases - by El Forum - 12-05-2009, 05:50 PM



Theme © iAndrew 2016 - Forum software by © MyBB