H
H
hollanditkzn2018-02-21 14:11:31
Yii
hollanditkzn, 2018-02-21 14:11:31

Why doesn't the model see the attribute?

I added a new column saalry to the table, But when I type it in by hand, it says Getting unknown property: app\models\User::salary, Although all the attributes are added there. Therefore, I decided to do it through gii, but to my surprise, this attribute is not there either. The question is why this is not done, but it is possible to display it only in this way, if I enter in the model

class User extends ActiveRecord
{
    public $salary;
...
}

Then everything works fine, and displays correctly
Displays it as a property
object(app\models\User)[114]
  public 'salary' => string '27000' (length=5)
  private '_attributes' (yii\db\BaseActiveRecord) => 
    array (size=15)
      'id' => int 2
      'username' => string 'hr' (length=2)
      'active' => int 1

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Fedorov, 2018-02-21
@hollanditkzn

Most likely you have the schema of this table cached and the data is taken from the cache in which this column does not exist. Try clearing the cache

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question