we can connect to multiple databases in codeigniter in same application, to achieve this only few configuration is necessary to be made in your database.php config file.

By default CI have following line of code to connect to one database instance:

So, for another database connection you just have to create another array of connection as follows:

and to load and use second instance just load the database and use it as follows: