I already have a web app and now i'm trying to introduce a multi-tenancy concept in it. I was wondering how to manage many databases? I presently have a main database that holds a users table, and other impertinent tables for this question. But my main struggle is that I have a league table that has a 'database_name' which I use to set my MySQL connection with depending on the league the user choose.
Is there a better way to do this?
Thanks :)
The concept you are using is fine. You can also, for example, just use league.name
(if league has a name) as the database name, or add some prefix/sufix to the name. I'm not sure if you are choosing one of multiple defined connections or are you changing the connection's database name in the config. I would suggest the second option.