The application (yii2) is to support many branches (each branch has its own database - databases for each branch are identical)
When logging in, I would like to select a database and connect to this database in addition to the login and password.
Or maybe a better solution is one database and, for example, in each table ID_department. Then, after logging in, the user would choose which branch he would like to work at …
Please give me some hints.
ps. Sorry for my English.
one suggestion is using one single database, add branchId in every transaction table then have one branch_user table where the user is matched to a branch. after login, you can either choose a branch to work with or get the branch assigned to user from the table. In the second scenario, the admin will assign a user to a specific branch.
In either scenario, every called to CRUD or any actions, you have to get the branchId first from branch_user table. Hence, the data will not be mixed up.
You can create one database per branch but I think it would be more difficult since you need to manage the database connection dynamically.