I am trying to define relationships in an ActiveRecord model class, but the problem is that our database is too large and has many relationships. So there is an easier way to declare a relationship in only one model, so that Yii can understand the relation for every other model to which it refers.
public function getBill_details()
{
return $this->hasMany(bill_details::className(),['company_bill_id'=>'id']);
}
public function getCompany()
{
return $this->hasOne(company::className(),['merchant_c_id'=>'id']);
}
I created two functions for two relationships. Similarly, I have about 80 relationships in one table, so there is an easier way to do this.
source
share