There may be times when you require your application to connect to more than one database or database server. For example, imagine you managed an online shop, and you may wish to have one database to handle customer orders, billing, invoicing, and so on, and another database to store and maintain product and stock information. CodeIgniter can be configured to use many database instances, and the following section shows how you do it.
In order to let CodeIgniter interact with two or more databases, we'll need to amend a few settings in the config
file at:
/path/to/codeigniter/application/config/database.php
Scroll down to the bottom of the file and copy the following into it. Remember to replace hostname
, username
, password
, and database
with the correct details for your setup.
$db['database1']['hostname'] = ''; $db['database1']['username'] = ''; $db['database1']['password'] = ''; $db['database1']['database'] = 'database1'; $db['database1'...