问题
I need to get my User
info and when I call
$this->User->find('first', array('conditions' => array('User.id' => $user_id)));
the result contains just some of the fields.
I've currently updated database schema. On dev server it runs fine and returns all fields but on the production server those new fields are missing. Those servers have exactly the same configuration.
I've already tried to remove contents of app/tmp/cache/models
and I am using File
engine for caching.
The schema.php
file is up to date, the contents of files in app/tmp/cache/models
indicate that those fields are present but I have not been able to retreive them on the production server. The only difference perhaps is database and debug level. I've tried copying the database and using it with the dev server and that worked well.
I cannot obviously set debug to 2 on the production server.
Did anyone of you experience any sort of similar behavior?
PS I am using Cake 2.3.3
回答1:
The answer was actually pretty simple. I had to remove not just the contents of app/tmp/models
, but what actually made it work was removing of the contents of app/tmp/persistent
.
回答2:
My answer differs from @Elwhis's slightly. I'm on Cake 2.4.5. For me there was no app/tmp/models
directory or app/tmp/persistent
. models
and persistent
were both under app/tmp/cache
. Just like @Elwhis, looking in the app/tmp/cache/models
directory showed the missing fields, so it was confusing.
To fix, I deleted all files from app/tmp/cache/persistent
. Note that if you delete the directory itself, you'll get a 500 error from CakePHP.
I recommend adding the deletion of files in that directory to your deployment process.
回答3:
Elwhis: The answer was actually pretty simple. I had to remove not just the contents of app/tmp/models, but what actually made it work was removing of the contents of app/tmp/persistent.
This still works to CakePHP 3, it fixed my problem!
Update 1
There are a simple way to clean up the cache with Bake CLI Tool, following below:
Cache Shell Command
To clear one cache config:
bin/cake cache clear
To clear all cache configs:
bin/cake cache clear_all
来源:https://stackoverflow.com/questions/16568818/cakephp-find-returns-results-with-missing-fields