where( id , 1)  &nbs..."/>
溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

thinkphp-更新數(shù)據(jù)update函數(shù)

發(fā)布時間:2020-09-08 20:55:42 來源:網(wǎng)絡 閱讀:1238 作者:素顏豬 欄目:web開發(fā)

說明

update 方法返回影響數(shù)據(jù)的條數(shù),沒修改任何數(shù)據(jù)返回 0

示例1

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

輸出

1

數(shù)據(jù)中包含主鍵形式

示例2

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

輸出

1

使用SQL函數(shù)或者其它字段進行更新

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


向AI問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權內(nèi)容。

AI