I'm trying to connect to db dynamically through:
DB::disconnect('mysql');
Config::set('database.connections.mysql.database', 'db_1');
When I use DB::table('table_from_db_1')->...
, it works perfectly. I get data from db_1
;
However, when I try to get DB::connection()->getDatabaseName()
, it still returns the original db name and NOT the db_1
.
Question:
- Why is this happening?
- How do I efficiently test if I have actually connected to the dynamic database?