Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Laravel(Eloquent,Fluent ...)中是否有一种方法可以更新一行,如果该行不存在,它将被插入?
Dunno id Laravel 有这样的方法,但是使用 mysql 你可以用这样的查询来做到这一点
INSERT INTO t SET c1='foo', c2='bar' ON DUPLICATE KEY UPDATE c2='bar'
您必须在此表上有一个唯一索引才能使技巧起作用