I'm confused and clueless on how to:
- Add a trigger to a postgresql db once the db has been set up, i.e. adding a trigger by clicking a hyperlink
- Write a trigger function so that it deletes a specific row after a week has passed since the trigger was written.
This is the sequence once events just for clarity
- Admin sees entry in db via a php generated html page.
- Admin clicks 'approve' hyperlink next to db entry.
- This creates a trigger in the db to delete that specific row after 1 week has passed.
I need help with step 3
Would an alternative way of doing this be to have a trigger on the table, so that when a row is inserted a new trigger is created which checks the value of an 'approved' column for that row. When the Admin clicks 'approve' in the html page the word 'yes' is inserted to the 'approved' column for that row. The trigger will detect this and add a new trigger to delete the row after a week?
As you can tell i'm really not sure which way to do it and how to do it so any feedback would be much appreciated. Thanks.