Load different database depends on user

Hello community. I have this idea where my website is served on single domain . but has different companies and users. for example user A login to my website and depends on his company he would be connected to database 1 . user A login to same website but he has different company so he wuould be connected to database .
I don’t want to use multi companies and restrict users though user permission because I want different databases . so it looks like multitenant but with single domain . and site are loaded depending to users .
any ideas ?