thinkphp5更新数据时在某个字段基础上加值

发布时间:2019-03-06 17:18:35 浏览量:100

db('order')->where('id',1)->update([
    'pay_price'     => Db::raw('pay_price+100'),
    'pay_time'      => date('Y-m-d H:i:s'),
]);
$consume_id = db('consume_log')->insertGetId([]);
array_walk($data, function (&$value, $key, $consume_id) {
    $value['consume_id'] = $consume_id;
}, $consume_id);