Answer the question
In order to leave comments, you need to log in
Duplicate compound key error in MySQL. How to ignore these situations?
I created a clean project and added 'illuminate/database' to it to avoid writing sql code. The table has a composite key: field1 and field2. When adding an existing entry, an error appears:
Fatal error: Uncaught PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry...
If an error occurs, the script stops its execution. How can I skip this error and continue working?
You can check before adding, but with large volumes - this is not good.
To add an entry, I use Capsule::table('single')->insert($array);
Thank you for your help.
Answer the question
In order to leave comments, you need to log in
Here is how I solved this problem:
Capsule::table('single')->updateOrInsert($array, $array);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question