It should be that the structure of the database table has been cached. Delete the runtime folder or execute
//清理指定表结构缓存数据 Yii::$app->db->getSchema()->refreshTableSchema('{{%post}}');//这里post是出去表前缀的表名 //清理所有表结构缓存数据 Yii::$app->db->getSchema()->refresh();
Done!
Recommended learning tutorial: yii framework
The above is the detailed content of After yii2 adds a field to the database table, the corresponding model cannot recognize the attribute.. For more information, please follow other related articles on the PHP Chinese website!