0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【Laravel】タイムスタンプがないテーブルを更新する

Posted at

#環境
・windows10
・PHP(7.3.6)
・Laravel(5.8.27)
・MariaDB

#問題
インスタンス作成

=> App\Post {#2960}

レコード挿入

=> "title 1"
$post->body = 'body 1';
=> "body 1"

そしてsaveメソッド

すると
Column not found: 1054 Unknown column ‘updated_at’ in ‘field list’
というエラー表示

#解決
こちらのサイトが参考になりました
・[【Laravel】タイムスタンプがないテーブルを更新(保存)する方法]
(https://nori-life.com/save-a-data-without-timestamps/)

上記エラーはupdated_atカラムとやらがないのが原因なので
日付情報を記録するタイムスタンプ機能を無効にすればいいらしい

=> false
$post->save();
=> true

成功

0
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?