GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Business Programming question (https://gfy.com/showthread.php?t=1301669)

freecartoonporn 07-25-2018 02:01 AM

Programming question
 
How to handle auto delete posts in mysql ?

i am working on webapp where users upload pics and choose expire date in future e.g. 10 minutes, 1 hour, 1 day, 1 month, 6 months, 1 year from the date of post creation.

How can i delete only those posts which are set for auto delete and whose date is expired ?

i can think of many ways., but cant decide which one to choose .


obviously cron job every minute will delete the expired posts.,

so should i save post_creation_date and post_expiration_date in datetime format or in unix timestamp format.

Thanks for your time.

i need logic, i can code mysqlf.


anybody ?

redwhiteandblue 07-25-2018 02:20 AM

I would have an expiration time in unix timestamp format, and when pulling out rows to display them or whatever else, have a condition on the query that only pulls rows that are before their expiration time. So rows that have gone past the expiration time appear to have been deleted even though they're still in the database. Then you can periodically delete them properly.

magneto664 07-25-2018 02:45 AM

keep your server time & unix timestamp format to avoid people from time zone +12 or -12 :)

freecartoonporn 07-25-2018 02:49 AM

Quote:

Originally Posted by redwhiteandblue (Post 22310835)
I would have an expiration time in unix timestamp format, and when pulling out rows to display them or whatever else, have a condition on the query that only pulls rows that are before their expiration time. So rows that have gone past the expiration time appear to have been deleted even though they're still in the database. Then you can periodically delete them properly.

thank you.

freecartoonporn 07-25-2018 02:52 AM

Quote:

Originally Posted by magneto664 (Post 22310838)
keep your server time & unix timestamp format to avoid people from time zone +12 or -12 :)

i read this more times than i should and i still dont understand what are you trying to say.,

but i get your point.

but that doesnt matter in my case,

as while inserting records current time + expire after time = expiration time.

so there is no timezone issue., i guess., but i may be wrong.

freecartoonporn 07-25-2018 02:56 AM

i can think it like this way.

post creation time = X
post expiration timeframe (10 minutes, 1 hour, 1 day etc) = Y
post expiration time = Z

X + Y = Z

and my query would become,

if Z > current time {
remove records.
}

but Z gets changed everytime user edits post and changes expiration timeframe.

thanks

Klen 07-25-2018 03:40 AM

Quote:

Originally Posted by freecartoonporn (Post 22310844)
i can think it like this way.

post creation time = X
post expiration timeframe (10 minutes, 1 hour, 1 day etc) = Y
post expiration time = Z

X + Y = Z

and my query would become,

if Z > current time {
remove records.
}

but Z gets changed everytime user edits post and changes expiration timeframe.

thanks

Maybe two columns called "original time" and "updated time" ?


All times are GMT -7. The time now is 02:13 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123