• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How save in to two server database

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

#2
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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.