My project is based on multi-user SaaS.
I have several clients (companies), and each client has several users - all of them will use the same database layout.
Each client has its own database, so during user authentication, I want to create a main database that connects the user to the database for this user.
The structure of each database is identical ... only the data is different.
Thus, we can store different databases for different companies that are not going to mix data in the database.
The number of clients (and therefore the number of databases) is unknown when the application is written, so it is not possible to include all connections in the bootstrap script.
Now, what I want to do is dynamically change the connection to the database that is in the bootstrap, or you have the ability to dynamically create a new connection for user login. Is there a simple solution for this in Yii and still use AR, a query builder?
I saw this solution, but it didn’t work for me http://www.yiiframework.com/forum/index.php?/topic/5385-dynamic-db-connection/
This is what my configuration file looks like for a script running a single database, I want to call the main database, which controls which database the user belongs to, and the application uses any idea in Yii?
<? php $language = 'en'; $currencyBaseCode = 'USD'; $theme = 'default'; $connectionString = 'mysql:host=localhost;port=3306;dbname=master'; $username = 'root'; $password = 'YOUR PASS'; $memcacheServers = array( // An empty array means memcache is not used. array( 'host' => '127.0.0.1', 'port' => 11211, // This is the default memcached port. 'weight' => 100, ), ); $adminEmail = 'EMAIL ADDRESS'; $installed = true; // Set to true by the installation process. $maintenanceMode = false; // Set to true during upgrade process or other maintenance tasks. $instanceConfig = array(); //Set any parameters you want to have merged into configuration array. //@see CustomManagement $instanceConfig['components']['request']['hostInfo'] = 'website url'; $instanceConfig['components']['request']['scriptUrl'] = '/app/index.php'; $urlManager = array (); // Set any parameters you want to customize url manager. ? >