无法使用 cakephp 关联模型

Can't use cakephp's assosiation model

不能使用cakephp的关联模型

我设计了图像等数据库模型,并编码了模型关联,但无法从学生模型访问 stoc_wish 和 ctos_wish 模型。

// student.php
class Student extends AppModel {
    public $belongsTo = array('Team');
    public $hasMany = array('Stoc_wish', 'Ctos_wish');
}

// stoc_wish.php
class Stoc_wish extends AppModel {
    public $belongsTo = array('Student', 'Cuser');
}

// ctos_wish.php
class Ctos_wish extends AppModel {
    public $belongsTo = array('Student', 'Cuser');
}

请多多指教

CakePHP 版本 => 2.6

enter image description here

Class CakePHP 2.x 中的名称必须采用驼峰式大小写,as described in the documentation,并且必须与您的 table 名称的带下划线的版本相匹配。如果他们不这样做,您必须在模型中设置 $useTable 属性。

这同样适用于模型文件名。

关注 CakePHP conventions 很重要。您越遵守约定,您需要的配置就越少。