I've this project where a different database should be used based on the current user. I'm using codeigniter with the Datamapper extension.
Ideal would be to set a different connection group in a controller which I can use in my datamapper models like:
var $db_params = 'user_specific';
However unlike the config params, the database params don't seem to be accessible from inside a controller. I did find a way where you needed to pass a variable ($db) when creating a new datamapper object in an answer to this question.
$customers = new customer(NULL, $db);
// The NULL I would need becuase the constructor expects an ID or nothing by default
However, most models would use the dynamic settings so it is a lot of work adding the $db variable everywhere... Is there any other solution so I can just do
$customer = new customer();
// And in my model use the dynamic 'config' settings like
var $db_params = 'user_specific';
It would be a great help. Thanks in advance.