Connecting to multiple databases in codeigniter with different hosting server

I am working on an e-commerce web application.

I am developing it using PHP and codeigniter frameworks.

I have 4 panels:

  • Administrator
  • Seller
  • User / Client
  • System managers

I have two hosting domains:

  • Go-dad
  • Bluehost

My admin, custom, sales web apps are on Go-Daddy and for generating all types of reports for admin and sys managers, I am developing another web app on Bluehost server.

The web application on Bluehost is for system managers only, and they search for and manage an accounting-related module.

My question is: Can I use the database on Go-Daddy's hosting server in the system managers web application that resides on Bluehost's server to generate graphical reports for sale?

I'm just a little confused.

+3


source to share


1 answer


If you want to run php application on Bluehost Server but your database is on Go-Daddy hosting server. Modify the application / config / database.php file on the Bluehost server. This file contains the configuration information for the aggregation code about the database used. in this you can specify data such as ip, port, dns, etc.

You can define an external database in the $ db ['default'] ['hostname'] setting.

You will need to find what your external database address is through your web host most likely. Some hosts also restrict external access by IP address, so you may need to set that as well.



the database.php file looks something like this:

$db['default']['hostname'] = '198.xxx.xx.66'; 
$db['default']['username'] = 'root';
$db['default']['password'] = 'xxxxxx';
$db['default']['database'] = 'm000db';
$db['default']['dbdriver'] = 'mysql';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;

      

0


source







All Articles