[英]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 tinker
在sqlite
创建了以下记录。
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.