Answer the question
In order to leave comments, you need to log in
Why doesn't Yii2 allow using ActiveQueryInterface in attributes?
If there is a code in AR
/**
* @return ActiveQuery
*/
public function getLabel()
{
// какой-то код
}
$AR->getLabel()
if you access through $AR->label
, then there will be no ActiveQuery anymore, because. the method __get BaseActiveRecord.php will not missNote: While this concept looks similar to the object property feature, there is an important difference. For normal object properties the property value is of the same type as the defining getter method. A relation method however returns an yii\db\ActiveQuery instance, while accessing a relation property will either return a yii\db\ActiveRecord instance or an array of these.
Answer the question
In order to leave comments, you need to log in
Note: While this concept looks similar to the object property feature, there is an important difference. For normal object properties the property value is of the same type as the defining getter method. A relation method however returns an yii\db\ActiveQuery instance, while accessing a relation property will either return a yii\db\ActiveRecord instance or an array of these.
Yii2 docs
I have no connections, but the same logic applies.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question