One Project multible Databases for multible Customers

Hello everybody
I have now completed my project and installed it on my webhost.
Now it comes to the control of the customer. I mean, according to whether what is url addressed should another customer database to be addressed. The goal is that I need only one application (project) and, depending on customer use another database.

In the project I have a connection defined called “conn_mysql”, these values I would like to change, depending on the customer call (url).

For example

https://Hostname/Company1
conn_mysql = Database1

https://Hostname/Company2
conn_mysql = Database2

both use the same Folder like /Foldername/Application/

is that possible?

http://www.scriptcase.net/docs/en_us/v81/manual_mp.htm#scriptcase-macros/scriptcase-macros ?? This one?

Hi rr, i don’t understand what you mean? witch one?

I think rr was referring to sc_change_connection()

Hello Salvatore,

Concretely the answer is Yes, you can. However, this practices you only will suffer to much making a maintenance. For every application you must edit the connection using sc_change_connection() or sc_connection_edit(), in the application init event:


if (user == boss){
    // change from employ connection to boss
    sc_change_connection("employ_connection", "boss_connection");
}

Not exactly manfred. Best way is to use sc_edit_connection, this Works at session level, you just have to use it once (on login for example)

You are completely right! I did not know about stateful db connection. Nice advice.

Hello everyone,

sorry for the delay.

i don’t now if you are understanding my correctly, or i don’t understand you. the problem is not user specific is db specific. i have an application for driving schools. at the moment if i setup my application for a new driving shool i create a new subdomain and a new folder for this driving school on my host and then copy all SC application files and folders in this new folder. then i create a database for this driving school and create the db structur. then i configure the connection for this database. the problem is, if i create an update for the application, so i must copy all the files in all customer folders on my host. the question is can y hold one folder with the application data and can i redirect the driving school via htaccess to there database?

if comes this driving school XY (subdomain) then go to …/XY/my_connect.sql and then redirect to SC Application

somthing like that?

it seems your business model could works by implementing a multitenant database (very hard). or, create a database per user (not so hard) and change the conection when the user logs in.

may be that works.

  1. create the enterprise profile (database, subdomain, etc.), (in production environment you must create the database profile).
  2. parse the url and switch the database regarding to the url in the login app. (macro sc_edit_connection etc)

thanks frank,

i beleve the problem in your solution is if we have 2 identical user names in different Company ore whats up with “admin”. i leve it at the moment, if i have hunderts of Companies, i think the staff that works then for me, there write a new version of the hole Application. :-)))

If you use the same database using multitenacy you should rewrite the constraints in order of prevent issues like that (when users has the same name for example), if you switch the database (a database for company), that wouldn’t be a trouble.