久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

update() 后返回集合?

Return Collection after update()?(update() 后返回集合?)
本文介紹了update() 后返回集合?的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

使用 Raw,如何返回更新行的集合?

Using Raw, how to return collection of updated row?

例如:

$updated = DB::table('users')->where('id', 1)->update(['votes' => 123]);

我期待 dd($updated) 返回更新后的集合行,但它返回了 1.

I was expecting dd($updated) to return updated row of collection but it returned 1.

{{$updated->votes}} should return 123

推薦答案

它不是這樣工作的.你不能指望這個(gè)查詢會(huì)返回一個(gè)對(duì)象:

That's not how it works. You can't expect this query will return you an object:

$updated = DB::table('users')->where('id', 1)->update(['votes' => 123]);

如果您只想按照問(wèn)題中提到的方式使用查詢生成器,則需要手動(dòng)獲取一個(gè)對(duì)象:

If you want to use Query Builder only as you mentioned in your question, you'll need to get an object manually:

$data = DB::table('users')->where('id', 1)->first();

使用 Eloquent,您可以使用 updateOrCreate():

With Eloquent you can use the updateOrCreate():

$data = User::where('id', 1)->updateOrCreate(['votes' => 123]);

這將返回一個(gè)對(duì)象.update() 將返回布爾值,因此您不能在這里使用它.

This will return an object. update() will return boolean, so you can't use it here.

這篇關(guān)于update() 后返回集合?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Magento products by categories(按類別劃分的 Magento 產(chǎn)品)
Resource interpreted as image but transferred with MIME type text/html - Magento(資源被解釋為圖像但使用 MIME 類型 text/html 傳輸 - Magento)
Is there an event for customer account registration in Magento?(Magento 中是否有客戶帳戶注冊(cè)事件?)
Magento addFieldToFilter: Two fields, match as OR, not AND(Magento addFieldToFilter:兩個(gè)字段,匹配為 OR,而不是 AND)
quot;Error 404 Not Foundquot; in Magento Admin Login Page(“未找到錯(cuò)誤 404在 Magento 管理員登錄頁(yè)面)
Get Order Increment Id in Magento(在 Magento 中獲取訂單增量 ID)
主站蜘蛛池模板: 免费精品视频在线观看 | 日日夜夜天天久久 | 99久久精品国产毛片 | 97视频在线观看免费 | 国产一区二| 午夜免费福利影院 | 久久久999精品 | 99re6在线视频精品免费 | 97国产爽爽爽久久久 | 一区二区三区视频在线 | 婷婷国产一区二区三区 | 91久色 | 午夜欧美一区二区三区在线播放 | 91麻豆精品国产91久久久更新资源速度超快 | 国产电影一区二区 | 国产99久久久国产精品 | 免费观看一级特黄欧美大片 | 日本免费小视频 | 欧美一区二区视频 | 久久午夜视频 | 精品国产一区二区三区性色av | 午夜精品久久久久久久星辰影院 | 亚洲网视频 | 久久久久国 | 狠狠操av| 亚洲一区二区三区高清 | 久久精品亚洲欧美日韩精品中文字幕 | 中文字幕在线观看av | 国产成人精品久久二区二区 | 日韩网 | 黄色在线观看网站 | 最新日韩欧美 | 97日日碰人人模人人澡分享吧 | 欧美一级片免费看 | 亚洲国产一区二区三区在线观看 | 一级一片在线观看 | 欧美日韩中文在线 | 一级毛片网 | 日日碰狠狠躁久久躁96avv | 欧美日韩国产精品激情在线播放 | 亚洲综合日韩精品欧美综合区 |