更新

2018-02-24 15:52 更新

更新數(shù)據(jù)表中的數(shù)據(jù)

DB::table('users')
            ->where('id', 1)
            ->update(['votes' => 1]);

自增或自減一個(gè)字段的值

DB::table('users')->increment('votes');
DB::table('users')->increment('votes', 5);
DB::table('users')->decrement('votes');
DB::table('users')->decrement('votes', 5);

也能夠同時(shí)指定其他要更新的字段:

DB::table('users')->increment('votes', 1, ['name' => 'John']);
以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)