CakePHP 2.0仍然需要在模型中声明$ name吗? [英] Does CakePHP 2.0 still need $name declared in the model?

查看:108
本文介绍了CakePHP 2.0仍然需要在模型中声明$ name吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的印象是,我们必须声明 - public $ name ='ModelName';在模式专用于PHP4。现在cakephp不再支持PHP4我认为不再需要在模型中的$名称声明。食谱仍然包含说明: http://book.cakephp.org/2.0 /en/models.html



这些模型没有我看到的效果很好。

解决方案



这只是早期食谱的一个残留。参见例如 http://book.cakephp.org/2.0/ en / models / model-attributes.html#name ,它提到了PHP4的兼容性,即使CakePHP 2.0不再适用于PHP4。



问题:不,你不必在你的模型中声明 $ name


I was under the impression that we had to declare - public $name = 'ModelName'; in the model exclusively for PHP4. Now that cakephp no longer supports PHP4 I thought there no longer needs to be $name declaration in the model. The cookbook still has instructions to include it though: http://book.cakephp.org/2.0/en/models.html

The models work fine without it from what I see. What is it used for, and why do I need it?

Thanks!

解决方案

It is just a leftover from the earlier cookbooks. See for example http://book.cakephp.org/2.0/en/models/model-attributes.html#name, it mentions PHP4 compatibility even though CakePHP 2.0 no longer works with PHP4.

So, to answer your question: no, you do not have to declare $name in your models.

这篇关于CakePHP 2.0仍然需要在模型中声明$ name吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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