Every tutorial or documentation regarding this subject is used with sql queries but never with new orm. I have two data sources defined in config/app.php: default and not_default with same tables and columns, when the user login the default database is connected. when the user clicks a certain button i need to change the connected database to not_default:
I achieved this so far:
ConnectionManager::get('default')->disconnect();
ConnectionManager::get('not_default')->connect();
ConnectionManager::get('not_default')->begin(); //dont know if required
when doing this: echo ConnectionManager::get('not_default')->isConnected();
I get 1 for not_default and 0 for default so it is connected
but the problem is when getting the model's TableRegistry the connectionname is still the default one!! How to change it???
I want to be able to get data using orm from database other than the default one.