[英]Column not found: 1054 Unknown column 'type_id' in 'field list'
I get this error when i tried to compile the controller of a class named Type in which i tried to create a classs called Compte, the relation is One type to Many compte.当我尝试编译名为 Type 的类的控制器时出现此错误,我试图在该类中创建一个名为 Compte 的类,关系是一种类型到许多类型。 Column not found: 1054 Unknown column 'type_id' in 'field list' (SQL: insert into comptes
( password
, type_id
, updated_at
, created_at
) values (hhh, 1, 2021-10-15 18:16:49, 2021-10-15 18:16:49))未找到列:1054 '字段列表'中的未知列'type_id'(SQL:插入comptes
( password
, type_id
, updated_at
, created_at
)值(hhh,1,2021-10-15 18:16:49,2021-10) -15 18:16:49))
The type_id does not exist in my code: enter image description here type_id 在我的代码中不存在:在此处输入图像描述
“type_id”不是您要插入的数据库表中的列。
那是因为您的数据库表中没有名为type_id
列。
在编写代码时,您为表定义了id_type
列,但您尝试将数据插入不存在的type_id
列!
Add field name in model like protected $fillable = ['type_id',....];
在模型中添加字段名称,如protected $fillable = ['type_id',....];
Or remove protected $fillable from model then all fields available for fillable或者从模型中删除受保护的 $fillable 然后所有可用于填充的字段
You create column name id_type
in the database, but in the model, you named it id_type
need to fix it in the data.您在数据库中创建列名id_type
,但在模型中,您将其命名为id_type
需要在数据中修复它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.