当前位置:网站首页>随手记:laravel、updateOrCreate 和 updateOrInsert 的区别
随手记:laravel、updateOrCreate 和 updateOrInsert 的区别
2022-08-08 20:24:00 【李斌的BLOG】
updateOrCreate()
和 updateOrInsert()
两个方法都是用来保存数据的时候方便操作“ 存在即更新,反之则创建 ”的
updateOrCreate
方法使用的是 Eloquent ORM
操作的数据库(支持自动添加创建和更新时间),updateOrInsert
方法使用的是查询构造器(不可以自动添加创建和更新时间)
updateOrCreate
返回值是\Illuminate\Database\Eloquent\Model
, updateOrInsert
返回的是 bool
。可以看两个方法的源码注释部分的 @return
下面是updateOrCreate
文档说明和源码
边栏推荐
- Yarn 总结(未完待续)
- 2022年云商店联合营销市场发展基金(MDF)介绍
- 源码分析MyCat专栏
- 学习与尝试 --> 事件风暴
- 分门别类输入输出,Go lang1.18入门精炼教程,由白丁入鸿儒,go lang基本数据类型和输入输出EP03
- C语言初阶-指针
- Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception
- Canvans:绘制饼图和玫瑰饼图
- Maykel Studio OpenHarmony Device Development Training Notes - Chapter 6 Study Notes
- 用 Antlr 重构脚本解释器
猜你喜欢
文档管理系统对于企业来说有哪些作用?
数据泵导出数据报39006是什么原因
Mei cole studio OpenHarmony equipment development training notes - the first learn notes
Superman is coming!Flutter realizes full-screen power animation!
Maykel Studio OpenHarmony Device Development Training Notes - Chapter 6 Study Notes
NAACL2022 NER SOTA—RICON学习笔记
tar zcf是单线程瓶颈
IJCAI 2022 | 图神经网络可以检测到异常吗?
0-1 背包问题
DCT变换
随机推荐
黑猫带你学Makefile第7篇:Makefile简单例程一览
学习笔记:第三章 栈与队列
The WPF main form calls User32's SetWindowPos to set the form to the top, which will cause the problem of grabbing the focus with other forms
实践篇1:深度学习之----LetNet之tensorflow2的实现
fillder4 keeps prompting the system proxy was changed, watch me solve it
如何用WebSocket打造Web端IM即时通讯聊天
技术分享 | 接口自动化测试之JSON Schema模式该如何使用?
一文教你普罗米修斯Prometheus的基础应用
买股票安全吗 资金能取出来吗
OpenEuler's Ways to Improve Resource Utilization 02: Effects under Typical Applications
Yarn 总结(未完待续)
Gartner:2022年全球半导体收入增长预计将放缓至7%,远低于2021年26.3%
【无标题】
莅临GOPS大会龙智展位,获取Forrester最新报告:《Forrester Wave:2021年第四季度企业服务管理报告》
“12306” 的架构到底有多牛逼?
Cesium中自定义材质material
IJCAI 2022 | 图神经网络可以检测到异常吗?
梅科尔工作室OpenHarmony设备开发培训笔记-第一章学习笔记
工程 (六) ——PointNet点云分类
PHP解析json数据,显示