My company has been setting up a different server for read and write access of mysql DB. Previously, we use custom php script. However, I was recently given task to create tools by leveraging CI. I've done it on test server. Now, I'm confused, how to implement it on live server.
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
I've made a simple libary that extend database functionality. You can modify it depend with what you need. http://rangga.net/splitting-read-write-codeigniter-database/
Setup multiple 'connection groups' for each server in your database.php config file, then in the Model:
See examples in: Connecting to Multiple Databases
Might it be easier, rather than doing this by IP, do it using MySQL users.
You could have two different users, one with all the write privileges like
INSERT
andUPDATE
, then another user with all the READ privileges likeSELECT
, or what ever you wish.Then what ever code is running on your write web server uses the write user and vice-a-versa?