0

I'm wondering if there's a way to add something to a mysql column (some form of string) in a specific row, or if this is even an issue at all with the way the server handles requests.

For example:

Each thread would have a row in a database, with comments being a column within the row, featured as a JSON array.

The function to add a comment would be ordered something like this

  • get Current Comment JSON

  • decode the json, and add the new comment to it

  • re-parse to JSON, and insert back into the database

However, this brings up the issue of this:

User 1 sends request to server to post a comment on a thread

User 2 sends request to post another comment on the same thread

  • User 1's request > loads current JSON

  • User 2's request > loads current JSON

  • User 1's request > adds the comment to its data, updates the database

  • User 2's request > adds the comment to its data, updates the database, removing User 1's comment entirely

is this even a problem? if so, what would be the steps needed to prevent this?

Barmar
  • 741,623
  • 53
  • 500
  • 612
Necrone
  • 1,217
  • 2
  • 9
  • 9

0 Answers0