S
S
Snewer2016-10-28 17:59:46
Yii
Snewer, 2016-10-28 17:59:46

Why is it impossible to access the connection through a getter?

Hello!
I create a connection in the model:

function getTest(){
    return $this->hasOne( ... );
}

When working with a model, when accessing the relationship using $model->getTest()->prop, an error occurs.
$model->test->prop works fine.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2016-10-28
@Snewer

Because if you access it as an attribute, this is one thing, but as a method, it's another.
$model->test analog of $model->getTest()->one()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question