This topic is locked
[SOLVED]

 Select Database based on login information

4/28/2017 20:43:32
PHPRunner General questions
need2sleep authorDevClub member

I'm looking for a way to have a project connect to the main database based on the login information entered by the user. For example you create the exact same CRM for a few different companies with different server connections but everytime you build a new version, you have to upload the changed files to multiple servers. This can obviously be very time consuming when your goal is to have 100s of clients down the road.
Is there anyone that has built a project for multiple companies so that when a user opens the login page example: "www.my-custom-crm.com"; and they enter their username and password, it makes the connection to the respective database based on the company associated with that user account?
Thanks,

A
alicea 4/28/2017

See if this post helps.

need2sleep authorDevClub member 5/3/2017

thanks for that! I remember reading this article long time ago and couldn't find it. The only thing that I can't wrap my head around is if I associate a "DBConnectionField" on the table of usernames, will I have to copy all usernames from each database to one main one? Has anyone tried this method?

mbintex 5/3/2017

Asking me the same thing.
Were should users and user rights be saved - in a central database for all customer databases? And how about user priviledges in the customer databases then?
I fear, this model is not thought to the end.
I´d like to see an easy method for mainting ONE project for several customers with a different database for each customers.

S
stiven 5/8/2017

or maybe you can just have a separate database just to store customers company information... maybe just like company name or some type of access code... when they entered the access code then you will know which database you can redirect the users to ... using this method http://asprunner.com/forums/topic/20126-single-project-working-with-several-identical-databases/

need2sleep authorDevClub member 5/8/2017



or maybe you can just have a separate database just to store customers company information... maybe just like company name or some type of access code... when they entered the access code then you will know which database you can redirect the users to ... using this method http://asprunner.com/forums/topic/20126-single-project-working-with-several-identical-databases/


Now that I think of it, we should be able to get this part done. The other issues I can see coming up are file uploads. For example if you ran a car sales website, you don't want all your images combining with all the other companies out there on the server. So it seems like we would have to create separate folders and store session variables. As well if you are running the email reader template that might present another issue. What do you all think of this?

Sergey Kornilov admin 5/8/2017

Storing images in the database seems like an easier option. Storing it on file system is also possible but more complicated and you will need to maintain a separate folder for each company somewhere on harddrive. Not impossible, but a bit more work.
You can use use 'PHP Expression' option to specify upload folder location and using session variable you can upload files to a separate folder for each client:

https://xlinesoft.com/phprunner/docs/edit_as_settings_file_image.htm