In the ExpressionEngine, we can have second or multiple database connections with default active database. In add-on development, it may be required to fetch the data/records from the external database rather than default active database.

We know that ExpressionEngine uses the libraries of CodeIgnitor. For this purpose we can have same approach of CodeIgnitor mentioned within user guide of Connecting to your Database.

Well, in the ExpressionEngine database connection values in being set within “/systemexpressionengine/config/database.php”. You can see the code of this file:

In the same file, you can set the second database connection values:


You can see, the second database connection values are the copy of first one by updating group as “ext_db” and other connection values.

The second database connection can be established with:


You can use all the database methods. For the SQL:


I hope, it would be fairly easy for you. 😊