php - Eloquent 模型添加没有 "created_at"和 "updated_at"字段

所以在我的 SQL 中,我的表只包含三个字段——行 ID、人员 ID 和状态 ID,我想使用 Laravel 模型添加新行,当我使用

$a = new AssignedStatus;
$a->person_id = $person_id;
$a->status_id = $status_id;
$a->save();

我收到 SQL 错误,提示在该表中找不到列“created_at”和“updated_at”。是否有可能摆脱它们并只插入行,或者使用 DB::table 连接更容易?

最佳答案

在 AssignedStatus 模型中你需要声明:

public $timestamps = false

关于php - Eloquent 模型添加没有 "created_at"和 "updated_at"字段的行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38159945/

相关文章:

r - 如何在 R 中绘制阶乘函数

apache-camel - 如何在 apache camel 中全局设置交换属性

javascript - 元素 innerHTML 摆脱事件监听器

ruby-on-rails - Rails 加入或包含有条件的 belongs_to

r - 如何使用来自多个其他列的所有非 NA 值创建新列?

types - Julia 中的大宽度整数?

git - 从 merge 请求创建补丁

regex - 如何在 Chrome Dev Tools 中过滤没有扩展的 XHR 请求?

Neo4j - 根据关系属性查找两个节点之间的最短路径

angularjs - 具有自动完成功能的 Angular 下拉菜单