Answer the question
In order to leave comments, you need to log in
How to insert a record if it doesn't exist and update if it exists + get its id?
How can I insert a record into a SQL table so that if it exists, it will be updated (or better, ignored), otherwise created + get its id?
I tried insertOrIgnore, updateOrCreate, it doesn't work as it should, namely I can't get the id or I get the id, but the record update doesn't work (SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question