Welcome Guest, Not a member yet? Register   Sign In
How save in to two server database
#1

(This post was last modified: 01-10-2020, 03:19 AM by vewuhico.)

https://1080ppornlist.com/
Reply
#2

(This post was last modified: 12-10-2019, 06:50 AM by Digital_Wolf.)

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['Server_B'] = array(/*DB settings for the server "B".*/); 

DB Config for CI 4:

PHP Code:
public $Server_A = [/*DB settings for the server "A".*/];
public 
$Server_B = [/*DB settings for the server "B".*/]; 

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);
$DB_B $this->load->database('Server_B'TRUE); 

Connecting to servers for CI 4:

PHP Code:
$DB_A = \Config\Database::connect('Server_A');
$DB_B = \Config\Database::connect('Server_B'); 

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';
$DB_A->query($Query);
$DB_B->query($Query); 


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




Theme © iAndrew 2016 - Forum software by © MyBB