例子:当字段po_num的值等于数组list_info中的po_num的值时修改数据库表po_rcv_receipt_line中某些信息:
数据库delivery_quantity字段的值 = 数据库中delivery_quantity的值+变量$list_info['write_quantity']
->inc('delivery_quantity', $list_info['write_quantity'])
数据库wait_delivery_quantity字段的值 = 数据库中wait_delivery_quantity的值-变量$list_info['write_quantity']
->dec('wait_delivery_quantity', $list_info['write_quantity'])
数据库last_update_date字段的值 = 当前时间戳
last_updated_by字段的值 = 变量$username
Db::table('po_rcv_receipt_line')->where([ 'po_num' => $list_info['po_num'], ])->inc('delivery_quantity', $list_info['write_quantity'])->dec('wait_delivery_quantity', $list_info['write_quantity']) ->update([ 'last_update_date' => time(), 'last_updated_by' => $username,]);
也可以把inc和dec换成setInc和setDec
来源地址:https://blog.csdn.net/weixin_46001736/article/details/132235243