Jump to content

Expiring timestamps


Delaran

Recommended Posts

Hey y'all, I've been programming a timestamp function into my SQLite database with much success.  In fact, I've learned more about PHP in the last two days than I did in the first two weeks.  However, while in a meeting with my boss he asked if there was a trigger to remove entries that are too old.  There is no such function implemented yet, so I've been toying around with my options.  I think it is something along the line of:

 

Create trigger delete_timestamp_expired BEFORE SELECT

begin

delete timestamp from wantdb where timestamp => (Y:M:D, "Month+2")

end;

 

I'm not sure how this would work but would appreciate any help in creating this trigger.

 

~dellyo

Link to comment
https://forums.phpfreaks.com/topic/49728-expiring-timestamps/
Share on other sites

I'm not sure about SQLite, in MySQL it would be something like:

 

CREATE TRIGGER delete_timestamp_expired BEFORE INSERT ON your_table
  FOR EACH ROW BEGIN
    DELETE FROM your_table WHERE DATE(your_table.timestamp) > DATE_ADD(NOW(), INTERVAL +2 MONTH);  
  END;

 

MySQL doesn't support triggers on SELECTs, are you sure SQLite does?

 

Best,

 

Patrick

Link to comment
https://forums.phpfreaks.com/topic/49728-expiring-timestamps/#findComment-244082
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.