Mar*_*cha 1 laravel laravel-5.4
嗨,我需要修改我的查询,我需要更新我的产品数量,只需增加它,这是我的代码与样本.
DB::table('product_warehouse')
->where('product_id', $product_id)
->where('warehouse_id', $warehouse_id)
->update(['product_qty' => $old_qty+$product_qty]);
Run Code Online (Sandbox Code Playgroud)
小智 5
您可以尝试两种方式:
DB::table('product_warehouse')
->where('product_id', $product_id)
->where('warehouse_id', $warehouse_id)
->update(['product_qty' => DB::raw('product_qty + ' . $product_qty)]);
Run Code Online (Sandbox Code Playgroud)
要么
DB::table('product_warehouse')
->where('product_id', $product_id)
->where('warehouse_id', $warehouse_id)
->increment('product_qty', $product_qty);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2490 次 |
| 最近记录: |