• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Multi Database, based on user

#1
I have searched quite a bit on this subject, and seem to keep falling short on how to make it work for my situation.

Background.
I have system in mind where a user logs in, and there database is loaded with their content.

My current design is thus:
Database 1 = Core, with tables for users, access privileges and database configurations.

Each database after that is specific to a company that has their specific data. 

After a user logins, their user info and database connection info is stored in the session. 

So user A, logins in and their Company A database is loaded.
user b login in and Company B database is loaded.

I have tried a number of ways and keep failing.  I may be going about this the wrong way.  Any suggestions or ideas would be greatly appeciated.
Reply

#2
You need to create multiple database configs in your /application/config/databse.php and load the default (at login) and specifically load their own database in all other files.
https://codeigniter.com/user_guide/datab...a-database

If you have done this; You need to show us some code and examples where it's not working and specify what you problems are.
Reply

#3
(01-17-2020, 12:39 PM)jreklund Wrote: You need to create multiple database configs in your /application/config/databse.php and load the default (at login) and specifically load their own database in all other files.
https://codeigniter.com/user_guide/datab...a-database

If you have done this; You need to show us some code and examples where it's not working and specify what you problems are.
thank you for your help.  Did some more searching and figured out how and where to load the individual databases.  My apologizes for not including code.  I wasn't sure what to show or where to start.
Thank you
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.