• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Making CI's DBstuff play nice with slave/master setups

#1
[eluser]moodh[/eluser]
Good evening!
I'm in the planning stages of a new project where we need to utilize a master/slave db-setup, and need some help with how to do this correctly.
My first thought was to simply set up two db groups, one to run selects on and the other to run insert/update/delete but seeing as the same sql statements always go towards the same server that should really not be necessary. Which leads me to extending/hacking the files in system/database as it's not extendable.

Is there a simpler way than to dive into the database-code or is that my only option?
Tips on how to actually do the fixing would be appriciated too, as I havn't started coding yet.

Thanks!

#2
[eluser]wh1tel1te[/eluser]
You could possibly create two config groups. Have a look at config groups here: Database Configuration

One group would be your select group (say "select"), and another would be your insert/update/delete group (say "update").

Then you could load the database class using the required group:

Code:
// I want to do some selecting!
$this->load->database('select');
// My select code goes here!

// Now I want to do some updating!
$this->load->database('update');
// My update code goes here!

More info here.

#3
[eluser]moodh[/eluser]
[quote author="wh1tel1te" date="1302494584"]You could possibly create two config groups. Have a look at config groups here: Database Configuration

One group would be your select group (say "select"), and another would be your insert/update/delete group (say "update").

Then you could load the database class using the required group:

Code:
// I want to do some selecting!
$this->load->database('select');
// My select code goes here!

// Now I want to do some updating!
$this->load->database('update');
// My update code goes here!

More info here.[/quote]

If you read my entry thats exactly what I want to avoid since it shouldn't be needed. I'm looking for a solution that maps the correct statement against the correct database setting without having to use $DB1->db->select(), $DB2->db->insert();

#4
[eluser]moodh[/eluser]
Pushing this one up a notch, anyone got an idea that doesn't revolve around the simple db-group concept? Sad

#5
[eluser]Unknown[/eluser]
does what this page said work?
https://gist.github.com/3137896


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.