CodeIgniter Forums
How save in to two server database - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: How save in to two server database (/showthread.php?tid=74434)



How save in to two server database - omid_student - 09-23-2019

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


RE: How save in to two server database - jreklund - 09-23-2019

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.


RE: How save in to two server database - omid_student - 09-23-2019

(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


RE: How save in to two server database - php_rocs - 09-23-2019

@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.


RE: How save in to two server database - omid_student - 09-24-2019

Thank you my friend


RE: How save in to two server database - jreklund - 09-25-2019

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.