我正在创建一个cakephp 2.x应用程序.在开发过程中途,我突然发现自己有一个"找不到表"的错误.
Missing Database Table
Error: Table blocked for model Parental was not found in datasource default.
Notice: If you want to customize this error message, create project\View\Errors\missing_table
Run Code Online (Sandbox Code Playgroud)
我检查了我的数据库,相关的表实际上就在那里.
接下来,我尝试调试模型.该模型可以访问该表.关于cakephp无法找到数据表的错误仍然存在.
这是我在调试模型时得到的结果:
\project\Controller\ParentalsController.php (line 5)
object(Parental) {
useTable => 'blocked'
useDbConfig => 'default'
id => null
data => array()
schemaName => null
table => 'blocked'
primaryKey => 'id'
validate => array()
validationErrors => array()
validationDomain => null
name => 'Parental'
alias => 'Parental'
tableToModel => array(
'blocked' => 'Parental'
)
cacheQueries => false
belongsTo => array()
hasOne => array()
hasMany => array()
hasAndBelongsToMany => array()
actsAs => null
Behaviors => object(BehaviorCollection) {
modelName => 'Parental'
defaultPriority => (int) 10
}
whitelist => array()
cacheSources => true
findQueryType => null
recursive => (int) 1
order => null
virtualFields => array()
__backAssociation => array()
__backInnerAssociation => array()
__backOriginalAssociation => array()
__backContainableAssociation => array()
findMethods => array(
'all' => true,
'first' => true,
'count' => true,
'neighbors' => true,
'list' => true,
'threaded' => true
)
}
Run Code Online (Sandbox Code Playgroud)
我还尝试了以下创建新表而不是模型使用.该模型可以访问新表,但CakePHP仍然无法检测到这些新表.
请指教.
Kim*_*cks 13
我在Google上搜索时发现了这个问题.
我有类似的问题.
我一直被提示我没有特定的表,当它显然在那里时我遵循惯例将表命名为复数形式.
我甚至几次清除蛋糕缓存文件无济于事.
然后我将调试模式从0更改为2.突然错误消失了.
然后我将调试模式从2更改回0.错误仍然消失了.
这是一种奇怪的行为.我不确定如何复制它.我正在写这篇文章以防其他人遇到与我相同的问题.
更新: 我已经意识到,对于我的一个经常出现此问题的应用程序,jenkins任务会以某种方式导致tmp/cache/persistent中的某些文件在错误的用户:group中出现文件.
我昨天纠正了这个问题.截至目前,这个问题还没有出现.如果问题在10天左右之后没有发生,我将声明问题是因为tmp文件不在正确的权限或用户:组所有权.