/** * @return \yii\db\ActiveQuery */ public function getActivities() { return $this->hasMany(Activity::className(), ['category_id' => 'id']); }
public function getActivity() { //同样第一个参数指定关联的子表模型类名 // return $this->hasOne(Activity::className(), ['id' => 'activity_id']); }
/** * @return \yii\db\ActiveQuery */ public function getActivity0() { return $this->hasOne(Activity::className(), ['id' => 'activity']); }