This topic is locked

Multi Tenent Application

1/29/2025 6:11:04 PM
PHPRunner Tips and Tricks
Peer Plaut author

I am developing an application to support multiple clubs designated by a field ORGID.
Each User has an ORGID Field associated with them.
Table Link Properties has the Master and Club_Master and the Details CR_Members
img alt

ORGID = ClubOne
ORGID=ClubTwo , etc.

Login is by email address.
Logging into the app - Both Clubs are shown and all members are shown.
Its been a few years since I have used PHP Runner and I believe a Where statement needs to go somewhere after logon.
I have a support ticket open, but I thought this problem might be of interest to others.
img alt
img alt
I look forward to any responses.
Thanks!
~P.

Peer Plaut author 1/30/2025

If I manually select the club after log on - the master detail relationship works.
How Can I ensure this using a value after logon?
I'm going to continue to work on this.
Thanks for any tips along the way.
img alt
img alt

Sergey Kornilov admin 1/30/2025

I'm afraid that you are confusing Master-Details relationship with multi-tenant applications. I think it would be beneficial to separate these two concepts.

I wasn't able to understand what exactly causes the problem here but the following article can certainly help you understand better how to build proper multi-tenant apps:
https://xlinesoft.com/blog/2019/10/03/saas-application-design/

Peer Plaut author 1/30/2025

Awesome - thanks for the article.
Yes I probably was confusing the two. :)
Thanks again!
~P.

Peer Plaut author 2/5/2025

Sergey-
I looked a the model you proposed and I think the complexity of managing multiple databases for small club memberships (10-50 members per club).
I worked with support to replace Before SQL Query to After Table Initialized. Because Before SQL Query broke the search.

But now users' get invalid logon. If I use cached logon, After Table Initialized works great! Users' get Invalid Logon now. :/

PHPRunner Version: 10.91 (Build 41974x64)

Using Database Dynamic Permissions for security model
Table Name: admin_users
Table Where users are stored CR_MEmbers

Table Name: Club_Master ~ Contains the Club Name, address, etc.

Security ~> Advanced Security Settings
Current Table: Club_Master
Users can see and edit their own data only
Users table: OwnerID Field ~>ORGID
Main table: OwnerID Field ~> ORGID

Table Name: CR_Members ~ Contains Club Members
Security ~> Advanced Security Settings
Users can see other users data, can edit their own data only
Users Table: OwnerID Field ID
Main Table: OwnerID Field ID

After Successful Login:
$_SESSION["ORGID"] = $data["ORGID"];

Based on the below article:
https://xlinesoft.com/phprunner/docs/addwhere.htm
The example
$query->addWhere("notes='".$_SESSION["UserID"]."'");

After table initialized
if (!Security::isAdmin()) //Removing this line makes no difference
$query->addWhere("ORGID='".$_SESSION["ORGID"]."'"); // after adding this line - every time I try to log on I get Invalid Login Removing this line, I can log in but the filter doesn't work.

Any ideas?
Thanks!
~P.