php - Map URL to MySQL databases -


I am interested in offering both of them. Now, some have suggested that I What can I think about this?

  1. Companya.mysoft.com will have a MySQL database which starts with the name company *. I.e., compan_mydb
  2. companyb.mysoft.com will have a MySQL database which starts with name companyb * .ie, companyb_mydb
  3. and so on.

In this way, new company accounts are easy to create and maintain.

Now, is it possible to change all these settings in inside Apache configuration files and MySQL ini, and PPIIII files? (I am using Apache, MySQL and PHP) It is better that I do not change my application

Edit: < / Strong> does not support MySQL Change the question to change it.

Edit2: Some suggestions that I have edited the PHP application to check the subdomain and select the correct database but it means the hosting code to complete the SAS version Will have to do tweaking Therefore, we must have two code versions, one for hosting, the other for mother-in-law , this is not what I want. It would be better if everything is done through a config file so that I have only one version of the code.

If you set up your PHP application correctly (some types of MVC design patterns Or framework), then you have a place where you specify the database name that is used by the subsequent all mysql functions in that request. This is only a matter of examining the request headers, grabbing (and validating) the company / db name prefix and using it in the mysql_select_db function.


Comments