【Laravel-Eloquent ORM】SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘updated_at‘ in ‘field

错误信息:

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://stackoverflow.com/questions/46700757

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值