I found this similar question but my problem is different.
I moved my CakePHP 2.2 application to another server. There exists no problem before migration. Most of the things works fine after migration. I can reach most of my database tables etc. But when I try to reach one of my table I get this error:
"Error 500: Table stats for model Stat was not found in datasource default."
To solve this, I checked this folder: "/app/tmp/cache/models"
In that folder there is a file for each of my tables
- myapp_cake_model_default_mydatabase_table1
- myapp_cake_model_default_mydatabase_table2
- myapp_cake_model_default_mydatabase_table3 etc..
But there is no file for stats table. Can it be the problem? Or how can I solve this?
(Permission for "/app/tmp/cache/models" folder is 755)
In Database.php I have this:
public $default = array(
'datasource' => 'Database/Mysql',
'persistent' => false,
'host' => 'localhost',
'login' => 'myuser',
'password' => 'mypass',
'database' => 'mydatabase',
'prefix' => '',
'encoding' => 'utf8',
);
Edit:
As I noted in thaJeztah's answer's comments, after removing all files inside app/tmp/cache/persistent
problem solved. CakePHP created new model cache files and it worked. After one year I found out the real problem. The problem was setting cake model files' clear duration. I set clearing cache to +999 days, so model files aren't regenerated. While making model changes you can set lower values for model cache clear:
Cache::config('_cake_model_', array(
'engine' => "File",
'prefix' => "myapp_". 'cake_model_',
'path' => CACHE . 'models' . DS,
'serialize' => ($engine === 'File'),
'duration' => "+999 days"
));
DESCRIBE stats
query. – Rebak