Most CakePHP programmers have seen this simple way of storing the development and production database settings in one file:
If you haven’t, check out Edward A. Webb’s original post from
This same technique can be used in the bootstrap.php file for other settings that change based on the server, for instance GoogleMap keys:
However, when baking a model, the database file only defines two types: prog and test so you pick one and end up with a model file with a line like:
in your baked model that doesn’t cause any problems right up until upload it to your live server late one night and start getting errors about being unable to make a connection- guess who did that?
The solution is simple: just define a default
somewhere in the file, now when you bake cake will give you the option of using the default connection which won’t add any problem-causing $useDbConfig to your model.
Hope this saves someone 20 minutes