注意(8):未定义的属性:

时间:2011-07-05 05:16:36

标签: cakephp-1.3

请帮我解决这个问题: 我错过了什么吗?

我收到以下错误:

注意(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' => ''
    )
);

2 个答案:

答案 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';