What if you used your code, but had an additional database config for those models that don't change? This additional database config would not be changed by the function you posted. In those models that you don't want to change, add the line
var $useDbConfig = 'static';
or whatever the name of your database config is that doesn't change. Then those that do change, you leave using the default config.