【Laravel-Eloquent ORM】SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘updated_at‘ in ‘field
程序员文章站
2022-04-07 18:09:02
错误信息:SQLSTATE[42S22]: Column not found: 1054 Unknown column 'updated_at' in 'field list' (SQL: update `table_name` set `STATE` = 1, `updated_at` = 2020-12-10 18:05:37 where `column_1` = xxx and `STATE` = 0 and `column_2` = xxx )解决方法:对应Model封装类中public...
错误信息:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'updated_at' in 'field list' (SQL: update `table_name` set `STATE` = 1, `updated_at` = 2020-12-10 18:05:37 where `column_1` = xxx and `STATE` = 0 and `column_2` = xxx )
解决方法:
对应Model封装类中
public $timestamps = false;
原因:
By default, Eloquent expects created_at and updated_at columns to exist in your tables. If you do not wish to have these columns to be automatically managed by Eloquent, then you need to set the $timestamps property in your model to false. Your file Building.php should look like:
意思是 默认的情况下Eloquent 预计表中有created_at和updated_at 这两列,会自动对这两列进行管理。问题在于表结构中没有这两个字段,timestamps属性默认为true,就出问题了。
参考:
https://*.com/questions/46700757
本文地址:https://blog.csdn.net/weixin_43967505/article/details/110958595