【问题标题】:Notice (8): Undefined property:注意(8):未定义的属性:
【发布时间】:2011-07-05 05:16:36
【问题描述】:

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

我收到以下错误:

注意(8):未定义的属性:Property::$Project [APP\controllers\properties_controller.php, line 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' => ''
    )
);

【问题讨论】:

    标签: cakephp-1.3


    【解决方案1】:

    在property.php中添加var $belongsTo = 'Project'

    【讨论】:

      【解决方案2】:

      你必须写在properties_controller.php

      var $uses = array('Project');
      

      然后你使用

      $projects = $this->Project->find('list');
      

      同时添加property.php

      var $belongsTo = 'Project';
      

      【讨论】:

      • 最好的解决方案是确保 Property belongsTo Project 正如@TuteC 所说,然后定义真正的关系并且查找将按预期工作。
      猜你喜欢
      • 1970-01-01
      • 2016-04-17
      • 2016-11-12
      • 2011-03-05
      • 2015-02-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多