Getting unknown property: yii\db\ActiveQuery::name

I just don’t understand why this error. I checked the table everything is there but when I use the model I get that error.

What is wrong?

do you have a field "name" in your table ?

Are you sure that you are getting field from ActiveRecord and not ActiveQuery?

Probably you have:




$query = Model::find()->where(...); 

$name = $query->name;



instead




$record = Model::find()->where(...)->one();

$name = $record->name;



Yes it is there.

I cannot really see the difference between those two.What does using "one()" adds?

I did




$query = Model::find()->where(...); 

$name = $query->name;



Let me try to put it in the way you propose and give you the feedback

http://www.yiiframework.com/doc-2.0/yii-db-activerecord.html#find()-detail