Answer the question
In order to leave comments, you need to log in
Should linking work in yii2 child class?
Why is the connection not clinging?
class Foo extends ActiveRecord{
....
}
class Bar extends Foo{
public function getOption(){
return $this->hasOne(...);
}
}
var_dump($bar->option);
Answer the question
In order to leave comments, you need to log in
Returns:
Undefined property: app\models\Foo::$option
The connection is formed by the attributes of the model. Most likely, in your BAR model, the ID attribute (or what do you have?) is not defined, according to which the binding is carried out.
Show the complete initialization code of the Bar model and also what you have in hasOne(...)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question