updateOrCreate()注意项

updateOrCreate()默认的主键是id,如果自增主键名不是id就要在模型中声明主键

protected $primaryKey = 'categories_description_id';
不然使用updateOrCreate()进行新增数据将无法新增,报错Column not found: 1054 Unknown column 'id' in 'where clause'
posted @ 2021-06-30 12:15  小林不会飞  阅读(1157)  评论(0编辑  收藏  举报