tags:

views:

176

answers:

2

Hello;

The company has an ERP application that supports only once company using one database, how to make the application support multiple companies and multiple databases using the same code?

The application is a PHP and the database is MySQL.

Thanks.

A: 

You could re-install it on a second server. If you have a license to do that of course. What ERP application is it?


Edit:

For our ERP product, I use a segment of the url to distinguish the database. e.g.

http://myserver.com/company1/customers

versus

http://myserver.com/company2/customers

All urls that are embedded in documents are relative urls so they stay within the same company.

Darrel Miller
Hi;Pardon my English, I forgot to mention that the application is ours, but the company developed it as a standalone product (i.e. delivered and installed at the client's server) but we want to present it as a hosted service on our servers such as Highcamp.
I'm thinking that if this is your company's application, and you wrote it, and you have difficulty with this sort of thing, you may have a bit of a problem that really needs an expert consultant for several months, rather than StackOverflow...
Curt Sampson
Well I know Stackoverflow won't re-write the whole thing, I am just looking for ideas on how to implement this. any ideas?
@Darrel: So you actually create sub folders on the server and copy the code there or do you use some sort of URL rewriting?
We have our own REST based framework that handles the URL routing. There is only one set of code that handles all the databases.
Darrel Miller
+1  A: 

It totally depends on the architecture of your application and your DB structure, if the refactor is too hard maybe the solution would be to have multiple instances of the ERP. Also as it is an ERP (with sensitive information of a company) you might have to install the instances in different servers, to ensure your clients won't be storing financial information with other companies in the same machine.

You can have one 'big' server virtualized. I'd suggest you to have a reverse proxy to redirect the requests from multiple subdomains to your virtualized guests. Also you can have a template of a virtualized server with Apache, PHP and your ERP installed ready to be installed in the virtualization host. When a client buy your product you just install and turn on that virtual guest and provide the client access.

victor hugo
Each instance should have its own copy of the database thus acheiving database separation. But could you ealborate a bit on that idea. Thanks