Home  >  Article  >  PHP Framework  >  After yii2 adds a field to the database table, the corresponding model cannot recognize the attribute.

After yii2 adds a field to the database table, the corresponding model cannot recognize the attribute.

王林
王林Original
2019-12-07 11:17:163143browse

After yii2 adds a field to the database table, the corresponding model cannot recognize the attribute.

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn