CakePHP 指定表名 [英] CakePHP specify table-name
问题描述
我有一个名为 entries
的表,其中包含一个名为 Entry
的关联模型.我逐步浏览了 CakePHP 网站上的博客教程.它指出不需要指定 table-name,因为它是根据模型名称计算的.( Post => posts
).
I have a table called entries
with an associated model called Entry
. I stepped through the Blog-tutorial on the CakePHP website. It states that the table-name does not need to be specified because it is computed from the models name. ( Post => posts
).
我怀疑 CakePHP 是否知道 Entry
是一个不符合名词的复数形式.那么如何设置模型使用的表格呢?我认为 CakePHP 会尝试访问表 entrys
.
I doubt CakePHP knows that Entry
is a non-conform noun when it comes to its plural form. So how can I set the table my model uses? I think CakePHP would otherwise try to access the table entrys
.
推荐答案
问题的答案是在模型中指定它.
The answer to your question is to specify it inside your model.
$useTable = 'yourtablename'
虽然,正如 Wooble 所指出的,您的怀疑是错误的.
Although, as Wooble noted, your doubts are wrong.
这篇关于CakePHP 指定表名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!