我用mysql编写简单的查询
update cart set cart_price=(select sum(total_price) from cart_items where cart_id=9) where cart_id=9我想用Laravel elequent实现同样的功能。我该怎么做呢?
谢谢。
发布于 2016-05-19 16:06:34
这是使用laravel query builder的查询。
DB::connection("YOUR_CONNECTION_NAME")
->table("cart")
->where('cart_id', 9)
->update([
"cart_price" => DB::raw('(select sum(total_price) from cart_items where cart_id=9)')
]);https://stackoverflow.com/questions/37317268
复制相似问题