Saturday, January 29, 2022

[FIXED] Deleting a specific row in SQL after dynamcic timeframe - PHP, MYSQL

Issue

Hey so i need a way to remove a row that is connected to a user after a dynamic time. Eg: Insert that your doing something for 15 minutes, after that 15 minutes i want to delete that row automatically.

There will be lots of rows (users doing stuff) in the database and i need them to all be removed after a custom time for each that is set by the user.

How would i go about this!

Thanks in advannce


Solution

You will need 2 things.

  1. a self_destruct_at or equivalent field that is a datetime. That will be set on creating the record.

  2. a worker process to go through ever X minutes (probably 1) and delete the comments that are older than the current time and the created_at + self_destruct_at time



Answered By - Austio

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.