CakePHP: Adding/deleting columns in the database after the application is Baked

If you had already baked the application and now if you made changes to the database by adding or deleting columns, then do the following:

1. Open "core.php" located at : app/config/core.php
2. Find the line which looks like: Configure::write('debug', 0);
3. Change it to Configure::write('debug', 2);
4. Refresh your application webpage.
5. Reset the line in core.php to Configure::write('debug', 0);

What basically this will do is refreshing the "model" cache.
Changing the debug level will ensure that all your databases changes are reloaded.

Following are the notes related to which debug level, you want to set.
/**
* CakePHP Debug Level:
*
* Production Mode:
* 0: No error messages, errors, or warnings shown. Flash messages redirect.
*
* Development Mode:
* 1: Errors and warnings shown, model caches refreshed, flash messages halted.
* 2: As in 1, but also with full debug messages and SQL output.
* 3: As in 2, but also with full controller dump. (NOTE: Not in CakePHP 1.3)
*
* In production mode, flash messages redirect after a time interval.
* In development mode, you need to click the flash message to continue.
*/

2 comments:

  1. Hey there,
    I deleted a row from one of my tables, and I changed the debug, as you suggested but I am still having this error.... SQL Error: 1054: Unknown column 'originating_table' in 'NEW' [CORE/cake/libs/model/datasources/dbo_source.php, line 673]

    Any advice?

    ReplyDelete
  2. Hi.
    Try setting the debug level to 3.
    Also, you say a row is deleted ? Did you mean column ?

    Did you delete 'originating_table' column ?
    If yes, the models are refreshed. I believe somewhere, you code has references to the deleted column.

    Make sure, your not references or using that deleted column in your code.

    Hope this helps.
    Thanks.

    ReplyDelete

Python contextlib for Timing Python code

If you've ever found yourself needing to measure the execution time of specific portions of your Python code, the `contextlib` module o...