How save in to two server database |
And so first you need to configure the database configuration, for this in the file "app/config/database.php" need to create two arrays one for server "A" the other for "B"... I do not know what version of CI you are using so I will provide the code for the third and fourth version of CI...
DB Config for CI 3: PHP Code: $db['Server_A'] = array(/*DB settings for the server "A".*/); DB Config for CI 4: PHP Code: public $Server_A = [/*DB settings for the server "A".*/]; Now in the place where you want to send the request you have to connect to these two servers using the code that I provided below... Connecting to servers for CI 3: PHP Code: $DB_A = $this->load->database('Server_A', TRUE); Connecting to servers for CI 4: PHP Code: $DB_A = \Config\Database::connect('Server_A'); Next, you only have to do the usual queries as you did earlier, but I still leave an example below... PHP Code: $Query = 'Here is your request'; That's all now your request to go to two databases at once. I would change this world, but God doesn't give me the source.
|
Messages In This Thread |
How save in to two server database - by vewuhico - 12-10-2019, 05:19 AM
RE: How save in to two server database - by Digital_Wolf - 12-10-2019, 06:47 AM
|