CakePhp查找不会获取hasMany关系

时间:2013-04-01 07:25:48

标签: cakephp find has-many

我有这些简单的模型:


// ActivityLog
class ActivityLog extends AppModel {

    public $name = 'ActivityLog';

    public $useTable = "activity_logs";

    public $hasMeny = array("ActivityLogMedia");

}

// ActivityLogMedia
class ActivityLogMedia extends AppModel {

    public $name = 'ActivityLogMedia';

    public $useTable = "activity_logs_media";

    public $belongsTo = array('ActivityLog','Media');

}

// Media
class Media extends AppModel {

    public $name = 'Media';

    public $useTable = "media";

    public $hasMeny = "ActivityLogMedia";

}

当我尝试这样做时:

$this->ActivityLog->find('all', array(
    'conditions' => array('ActivityLog.id' => $ret['ActivityLog']['id']),
    'recursive' => 2
));

Cake不会返回任何与ActivityLog相关的模型 任何人都可以给我一个解释和/或解决方案吗?

1 个答案:

答案 0 :(得分:1)

您有输入错误,$hasMeny应为$hasMany