我想知道为什么框架可能会有这种奇怪的行为。
如果我将事件模型中的关系定义为weird
或除此之外的任何其他名称interest
,则它可以正常获取类的对象Interest
。
public function relations()
{
return array_merge(
parent::relations(),
array(
'weird' => array(self::BELONGS_TO, 'Interest', 'interest_id'),
));
}
但是,如果我将名称更改为interest
它会返回null
public function relations()
{
return array(
'interest' => array(self::BELONGS_TO, 'Interest', 'interest_id'),
);
}
因此,只需将名称更改为兴趣意味着关系将返回null