说明

update 方法返回影响数据的条数,没修改任何数据返回 0

示例1

Db::table('think_user')
    ->where('id', 1)
    ->update(['name' => 'thinkphp']);

输出

1

数据中包含主键形式

示例2

Db::table('think_user')
    ->update(['name' => 'thinkphp','id'=>1]);

输出

1

使用SQL函数或者其它字段进行更新

Db::table('think_user')
    ->where('id', 1)
    ->update([
        'login_time'  => ['exp','now()'],
        'login_times' => ['exp','login_times+1'],
    ]);