Delaran Posted May 2, 2007 Share Posted May 2, 2007 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 More sharing options...
utexas_pjm Posted May 3, 2007 Share Posted May 3, 2007 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.