简体   繁体   中英

Connect with multiple database in codeigniter with different hosting server

I am working on E-commerce web application.

I develop it with PHP and codeigniter framework.

I have 4 panels:

  1. Admin
  2. Seller
  3. User/Customer
  4. System managers

I have two hosting domain:

  1. Go-Daddy
  2. Bluehost

My admin, user, seller panel web apps is on Go-Daddy and for generating all types of reports for admin and for system managers, i develop different web app on Bluehost server.

Web app on Bluehost is only for system managers and they are looking and managing accounting related module

My question is: Can i use a database on Go-Daddy hosting server in system managers web app which is on Bluehost Server for generating graphic reports for sells?

I am just an only little bit confused about it.

If you want to run the php app on Bluehost Server , but your database is on Go-Daddy hosting server. Change the file application/config/database.php on Bluehost server. This file contains codeigniter configuration details about database in use. in this you can specify the details like ip, port, dns etc.

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

You'll need to lookup what your external database address is through your web host most likely. Some hosts also restrict external access by IP address, so you might need to set that up also.

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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM