Welcome Guest, Not a member yet? Register   Sign In
Multi-User (instance) Project.
#1

Hi All,
 
Does anyone have suggestions on best practices to allow multiple users to access specific databases, from the same instance of the application using CI4?
 
I've developed a customer application using CI4, however other companies are interested in using the application. I do NOT want to copy the application for each company (with their own config) as this will cause major headaches with any sort of change management and maintenance.
 
My first thought was to replicate the database tables, prepend the table name with a unique identifier and tie the identifier to the customer "profile" and make this available via some variable or other. However I do not think this is robust enough or secure enough.
 
I'm now thinking of creating a separate database instances for each customer, and somehow identifying the correct database instance in CI4 (app->config->database.php), when the user logs in.
 
Any tips, suggestion or nudges in the right direction will be very much appreciated?
Reply
#2

I would definitely create separate databases per company. You can have a global database to deal with the logins and user profiles. In the user profile you can set the database name this user has access to. Then you can connect to this second DB with that database name.
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply
#3

(12-19-2020, 04:14 AM)68thorby68 Wrote: Hi All,
 
I've developed a customer application using CI4, however other companies are interested in using the application. I do NOT want to copy the application for each company (with their own config) as this will cause major headaches with any sort of change management and maintenance.

Selling three different systems as SaaS (all developed in CI3 and CI4) and hosting them on Amazon I’d say - think scalable from the beginning! Isolate the systems using different host names and hosting environments.
Reply
#4

(This post was last modified: 06-09-2022, 11:08 PM by clsmedia.)

You can select the appropriate database based on the subdomain. I did this once for testing and found no problems. I would probably test it harder before releasing it to production, although the idea itself works.

Edit: ok. now i saw how old this thread is.
Reply
#5

Thanks for Sharing!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB