I wasted a few hours on Saturday morning struggling with the fact that CakePHP on my production server refused to save to a newly added field on a table in my database, while everything worked beautifully on my dev server. After hours of debugging on the live server I suddenly remembered that, with:
in core.php, as it should be on a production system, Cake uses the cached model definitions in tmp\cache\models and would therefore ignore any changes in the underlying database until these were refreshed. Simply either:
- Change temporarily to
Configure::write('debug', 2);and then run your code before changing it back again or;
- Delete the contents of tmp\cache\models
and it will pick up your new field.
2 Replies to “CakePHP not saving to new field on production server”
Nice answer ……where is core.php located?
Hi. This post related to CakePHP 2, in which case core.php file is in the Config directory. In Cakephp 3, the debug setting is found in config/app.php, although I’m not sure whether it has the same effect on caching of models as it did in Cake 2 – the docs (http://book.cakephp.org/3.0/en/development/configuration.html#general-configuration) would suggests it only affects the debugging output, but they aren’t always as complete as they would ideally be.