CakePHP指定table-name [英] CakePHP specify table-name

查看:128
本文介绍了CakePHP指定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知道 code>是一个不一致的名词,当它涉及到它的复数形式。那么如何设置我的模型使用的表?我认为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指定table-name的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆