Custom Web Applications to Grow Your Business

(256) 429-8145

4 ways to fix cakePHP column or table field not showing in query

It is the simple things that sometimes consume most of you time on certain projects. It can be quite irritating trying to figure out why a simple issue like why a field that is clearly in the mysql table does not show up in the results of a simple query. I recently spent about two hours trying to figure what seems at first a simple fix. Here are some steps you can take to remedy the situation.

  1. First, do a query of the whole table and print an array of the results. For instance print_r($this->Auth->User()); for users table. This will give you an indication if the field is in the table or whether a misspelling is the culprit
  2. It could also be a cache issue. Delete all the cache files in log/cache/models
  3. If this does not work, alternate you debug number, from 0 to 2, vice versa
  4. The last option is to prevent cache altogether. Open your /app/config/core.php file and write

Configure::write('Cache.disable', true);

This disables cache altogether.