CodeIgniter Forums

Full Version: How save in to two server database
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi
I have two database in two server
Can i insert record a two database same time
Example when i execute below query
$this->db->set('title','asdsad')->insert('tbl');

Save this record in server A and server B same time

Thanks
Personally I would set up server A as a master server and B as a slave. That's something that should be done on server level.
(09-23-2019, 11:37 AM)jreklund Wrote: [ -> ]Personally I would set up server A as a master server and B as a slave. That's something that should be done on server level.
I know but can i use this feature with Codeigniter?
Because if it be,solution will be easy
@omid_student,

Of course you can use it with CI the catch is... do you have full control/access to the master and slave databases. In most cases (if you are using a regular hosting account, you probably don't) you may have to look at having a cloud database which should have this as a feature.

You could also, capture all updates going to the db server and send them to another server but this is a manual and not highly recommended solution.
Thank you my friend
I strongly suggest against it. There is nothing that we guarantee data integrity, one query might be OK on one server but not the other. And you will end up with mixed content.