Yii Dynamic DB Connection according to user with a master database

Closed - This job posting has been filled and work has been completed.

Job Description

My project is on the basis of multi-tenent SaaS.

I have multiple clients (companies) and each client has multiple users - they all will use the same database layout.

Each client has their own database, so during user authentication, I want to Build a master database that associates the user with a company database for that user.

The structure of each database is identical... only the data is different.

So that we can keep the different database for the different company, that will not going to mix in data in database.

The number of clients (and therefor the number of databases) is unknown when the application is written, so it is not possible to include all the connections in the bootstrap script.

Now, what I want to do is, dynamically alter the DB connection that is in the bootstrap or have the ability to dynamically create a new connection for the user signing in. Is there a simple solution for this in Yii and still use AR , query builder ?

I saw this solution but not working for me http://www.yiiframework.com/forum/index.php?/topic/5385-dynamic-db-connection/

need someone to fix my issue