0

it is possible that there are two duplicate rows of my database, exactly identical. In the function I used for its creation I called once $ resource-> save () and a few times $ resource-> update (), to modify after creation. There are no errors in the logs or that would make me think the operation went wrong. The two identical lines have the created_at field at 1 second from each other

2
  • If you specified unique constraints on some columns then this should not be happening but if you do not specify unique constraints then the database has no reason to reject inserts because there are other rows (mostly) the same. There are valid use cases where you'd want to have the same entry multiple times.
    – apokryfos
    Commented Oct 2, 2022 at 10:15
  • its a common problem with things like users double-clicking form buttons, or bad code that updates the database as a result of a GET request. Many browsers will prefetch content when the user moves the mouse over a button. They then click the button and the server sees 2 GET requests. GET should not create any side effects or change any state in the server
    – Snapey
    Commented Oct 2, 2022 at 17:20

0

Browse other questions tagged or ask your own question.