INSERT IGNORE using Laravel's Fluent

前端 未结 10 1273
执笔经年
执笔经年 2020-12-11 02:12

Is there a quick way to modify a SQL query generated by Laravel\'s Fluent to have an INSERT IGNORE instead of the usual INSERT?

I\'m trying

10条回答
  •  有刺的猬
    2020-12-11 02:51

    Option to avoid writing code is: https://github.com/guidocella/eloquent-insert-on-duplicate-key

    I have tested it just now - it works with my 5000 inserts at a time sometimes with duplicates...

    With it you will get these functions:

    User::insertOnDuplicateKey($data);
    User::insertIgnore($data);
    

提交回复
热议问题