请帮我解决这个问题: 我错过了什么吗?
我收到以下错误:
注意(8):未定义属性:Property :: $ Project [APP \ controllers \ properties_controller.php,第614行]
//这是发生警告的代码
$projects = $this->Property->Project->find('list');
并在project.php(模型文件)中
var $hasMany = array(
'Property' => array(
'className' => 'Property',
'foreignKey' => 'project_id',
'dependent' => true,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
)
);
答案 0 :(得分:1)
添加property.php var $belongsTo = 'Project'
。
答案 1 :(得分:0)
你必须写在properties_controller.php
var $uses = array('Project');
然后你用
$projects = $this->Project->find('list');
还要添加property.php
var $belongsTo = 'Project';