Php Laravel DB::表更新记录
我有这个疑问Php Laravel DB::表更新记录,php,pdo,laravel-4,Php,Pdo,Laravel 4,我有这个疑问 DB::table('product_options') ->where('product_id', $id) ->where('size', $selected_size) ->update(array('stock' => WHAT TO PUT HERE)); 在我放置了要更新的内容的更新部分中,我应该在此处放置什么以将数字减少1?使用递减法 所以我不需要更新方法,然后只是减量@是的,看看链接。你可以
DB::table('product_options')
->where('product_id', $id)
->where('size', $selected_size)
->update(array('stock' => WHAT TO PUT HERE));
在我放置了要更新的内容的更新部分中,我应该在此处放置什么以将数字减少1?使用
递减法
所以我不需要更新方法,然后只是减量@是的,看看链接。你可以传递你想减少的值,如果你需要的话,你也可以传递其他的列来更新。是的,你总是忘了在Laravel中这些额外的小部分,干杯,伙计
DB::table('product_options')
->where('product_id', $id)
->where('size', $selected_size)
->decrement('stock');