Creating and Update Laravel Eloquent

后端 未结 13 1452
广开言路
广开言路 2020-11-27 11:59

What\'s the shorthand for inserting a new record or updating if it exists?



        
13条回答
  •  执笔经年
    2020-11-27 12:51

    Isn't this the same as updateOrCreate()?

    It is similar but not the same. The updateOrCreate() will only work for one row at a time which doesn't allow bulk insert. InsertOnDuplicateKey will work on many rows.

    https://github.com/yadakhov/insert-on-duplicate-key

提交回复
热议问题