简体   繁体   English

Laravel-如何在sqlite中更新字段值

[英]Laravel - How to update field value in sqlite

On my laravel project, I created the following record in sqlite using php artisan tinker . laravel项目中,我使用php artisan tinkersqlite创建了以下记录。

   App\Note {#642
     id: "1",
     card_id: "2",
     body: "Some note for the card",
     created_at: "2016-06-19 22:18:34",
     updated_at: "2016-06-19 22:18:34",
   }

How can I change the card_id field to 1 instead of 2? 如何将card_id字段更改为1而不是2?

$note = App\Note::find(1);
$note->card_id = '1';
$note->save();

You can use Note model to update the card_id value. 您可以使用Note模型来更新card_id值。

$note = Note::find(1);
$note->update([
    'card_id' => '1',
]); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM