As you can see it checks for if the customer exists each time. Can anyone help me change the above so once it has checked it sets the customer database connection and does not check if they exist again please.
I know I'm missing lots of error checking etc but I just wrote this, once working I will add error checking etc.
Msg#: 4544941 posted 9:53 pm on Feb 12, 2013 (gmt 0)
You have a separate database for each customer? That's an unusual way of doing things. Normally, you would using a unique ID for each customer and use the ID as a key in tables of customer data. Having customer data in a database for each customer makes it so that you can't, for example, run any queries that return information about more than one customer at a time.
But ... if having a separate database for each customer is what you really want, you can't get around selecting the database each time.
Msg#: 4544941 posted 9:43 am on Feb 13, 2013 (gmt 0)
Yeah I intend on having a seperate database for each customer. If I explain the setup hopefully that will clear things up. I'm developing a system which I will sell to multiple customers. The code will be hosted on my domain however the customers database will be hosted on their domain. The thinking behind this is each customers data is their own, it isn't mixed with everyone elses.
The reason I didn't go the way Habtom suggested is because there could be hundreds of config files, meaning allot of if statements.
The content will be different based on the url, only as the data available is dependant on the url/customer database connection.
The code I've posted works however it checks each time, which is not exactly ideal. I've looked into using DEFINE but I'm still not sure I can do it that way.