使用增量更新Laravel查询生成器
嗨,我需要修复我的查询,我将需要更新我的产品数量,只是增加它,这是我的代码与样本使用增量更新Laravel查询生成器,laravel,laravel-5.4,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]); 您可以尝试两种方法: DB::table('p
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)]);
或
DB::table('product_warehouse')
->where('product_id', $product_id)
->where('warehouse_id', $warehouse_id)
->increment('product_qty', $product_qty);