Skip to content

Commit

Permalink
[8.x] Clarify insertOrIgnore is not just duplicate record errors (#…
Browse files Browse the repository at this point in the history
…7308)

* Clarify `insertOrIgnore` is not just duplicate record errors

* Remove explicit version from MySQL ignore effects link

* Describe consequence of ignoring errors

* Update queries.md

Co-authored-by: Taylor Otwell <taylor@laravel.com>
  • Loading branch information
shrink and taylorotwell authored Sep 14, 2021
1 parent 815905e commit 5af5c42
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion queries.md
Original file line number Diff line number Diff line change
Expand Up @@ -812,13 +812,15 @@ You may insert several records at once by passing an array of arrays. Each array
['email' => 'janeway@example.com', 'votes' => 0],
]);

The `insertOrIgnore` method will ignore duplicate record errors while inserting records into the database:
The `insertOrIgnore` method will ignore errors while inserting records into the database:

DB::table('users')->insertOrIgnore([
['id' => 1, 'email' => 'sisko@example.com'],
['id' => 2, 'email' => 'archer@example.com'],
]);

> {note} `insertOrIgnore` will ignore duplicate records and also may ignore other types of errors depending on the database engine. For example, `insertOrIgnore` will [bypass MySQL's strict mode](https://dev.mysql.com/doc/refman/en/sql-mode.html#ignore-effect-on-execution).
<a name="auto-incrementing-ids"></a>
#### Auto-Incrementing IDs

Expand Down

0 comments on commit 5af5c42

Please sign in to comment.