Hi all,
I'm trying to change the database connection based on a variable for several of my models. This variable will be based on user input (initially) and stored in the session after they are logged in.
I know that I need to set the connection service in the initialize function of the model - that works fine. The problem is I will have many databases (large datasets for multiple clients) and defining them all in the services container beforehand seems inefficient. I can create a new db service within the model using getDI() and set-> and that works - but it seems like the wrong way to do it to me.
Can anyone provide syntax on how to change the database name (will be variable) in a db service already initialized - rather than creating a new service within the model every time? I tried messing around with setParameter but couldn't get it.
So that ideally I can set a db service in the initial service container - and then just change the dbname parameter based on a variable whenever I initialize certain models?
Thanks!
-Matt