Andy Dawson (aka AD7six) and Felix Geisendörfer (aka the_undefined) presented in the last 24 hours solutions for switching the database configuration based on some criteria. These solutions work fine, but personally I use a different approach.

I try to avoid to add code to configuration files because those files shouldn’t contain any logic. Instead I use Subversion to manage different configurations. In my repository I have at least two folders for each project: a “trunk” folder where the development happens, and a “live” folder which contains the code (and configurations) for the live application. So if I put something online I just export the content of the “live” folder from the repository, and with it the “live” configuration.