我有一个像这样的数据库
====Group=====
id
name
====Member====
id
group_id
firstname
lastname
membersince
现在我在模特中使用了这种关系。
群组模型
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'member' => array(self::HAS_MANY, 'Member', 'group_id'),
);
}
会员模型
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'group' => array(self::BELONGS_TO, 'Group', 'group_id'),
);
}
所以有人可以告诉我这种关系是对的,还是我错过了任何帮助和建议会非常明显。