In EE2 we were able to connect to a secondary external database from within our plugins. In EE3 this doesn’t appear to work anymore. In our config.php file we have:
$config['database'] = array ( 'expressionengine' => array ( 'hostname' => 'localhost', 'username' => 'ee_user', 'password' => 'ee_pass', 'database' => 'ee_database', 'db_debug' => false, ), 'second_database' => [ 'hostname' => 'localhost', 'username' => 'second_user', 'password' => 'second_pass', 'database' => 'second_db', 'db_debug' => false, ], );
In the plugin we have:
$db2 = ee()->load->database('second_database',true);
We get the warnings:
Illegal string offset 'hostname' ee/legacy/database/DB.php, line 34
It appears that even though we setup everything to use a different database, EE is still connecting to the primary database. How do we fix this so we can access our second DB?