【问题标题】:What is the proper Cakephp Model Naming Conventions什么是正确的 Cakephp 模型命名约定
【发布时间】:2014-06-04 03:12:46
【问题描述】:

表格是“rate_chapters”

模型文件名为“rateChapter”

模型类名称是“rateChapter” 类 RateChapter 扩展 AppModel{ }//文件名为rate_chapter.php

当我查询这个模型时,我得到一个错误:致命错误:无法重新声明类

//在控制器中

$this->rate_chapter->find('all');

不了解命名约定。读了,但不清楚..

【问题讨论】:

  • 这还不够,显示你的代码

标签: php cakephp naming-conventions models


【解决方案1】:

表格:rate_chapters

模型:RateChapter

 $this->RateChapter->find("all");

模型文件:RateChapter.php

控制器文件:RateChaptersController.php

【讨论】:

    【解决方案2】:

    想通了。是 $this->RateChapter->find('all');

    【讨论】:

    • 但恐怕你没有使用 CakePHP 命名约定。你模型的文件名必须是 RateChapter.php 参考我的回答。
    【解决方案3】:

    您可以在以下位置找到所有命名约定:

    http://book.cakephp.org/2.0/en/getting-started/cakephp-conventions.html

    您发现模型总是单数(表格是复数)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-01-18
      • 1970-01-01
      • 2020-09-30
      • 2010-09-20
      • 2013-11-10
      • 2012-11-12
      • 2011-08-20
      相关资源
      最近更新 更多