您好,我需要修复我的查询,我需要通过增加产品数量来更新产品数量,这是我的代码和示例。
DB::table('product_warehouse')
->where('product_id', $product_id)
->where('warehouse_id', $warehouse_id)
->update(['product_qty' => $old_qty+$product_qty]);
您可以尝试两种方法:
DB::table('product_warehouse')
->where('product_id', $product_id)
->where('warehouse_id', $warehouse_id)
->update(['product_qty' => DB::raw('product_qty + ' . $product_qty)]);
Or
DB::table('product_warehouse')
->where('product_id', $product_id)
->where('warehouse_id', $warehouse_id)
->increment('product_qty', $product_qty);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)