Home > PHP Framework > YII > 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.

王林
Release: 2019-12-07 11:17:16
Original
3176 people have browsed it

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();
Copy after login

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!

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template