Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

detect duplicate insert

Is there an easier way to prevent a duplicate insert after refresh? The way I do it now is to select everything with the all fields except ID as parameters; if a record exists i don't insert. Is there a way to possible detect refresh?

like image 938
Eric Avatar asked Nov 21 '25 02:11

Eric


1 Answers

Assuming it's a database, you could put a unique constraint on the combination of "all fields except ID" and catch the exception on an insert or update.

like image 77
Austin Salonen Avatar answered Nov 22 '25 15:11

Austin Salonen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!