thinkphp 中更新數據字段,同時某字段值++操作(報錯TP5.1不支持的數據表達式:[exp]的解決辦法)


1.使用exp操作,如下,結果報錯

  TP5不支持的數據表達式:[exp]

$update['order_status'] = 2;
$update['pay_time'] = time();
$update['sale_number'] = array('exp','sale_number');
Db::table('think_order')->where(['order_sn'=>$order_sn])->update($update);

2.改為如下代碼:操作成功
$update['order_status'] = 2;
$update['pay_time'] = time();
$update['sale_number'] = Db::raw('sale_number+1'); //字段sale_number值+1
Db::table('think_order')->where(['order_sn'=>$order_sn])->update($update);


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM