Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 07-25-2018, 02:01 AM   #1
freecartoonporn
Confirmed User
 
freecartoonporn's Avatar
 
Industry Role:
Join Date: Jan 2012
Location: NC
Posts: 7,683
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 ?
freecartoonporn is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 07-25-2018, 02:20 AM   #2
redwhiteandblue
Bollocks
 
redwhiteandblue's Avatar
 
Industry Role:
Join Date: Jun 2007
Location: Bollocks
Posts: 2,793
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.
redwhiteandblue is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 07-25-2018, 02:45 AM   #3
magneto664
God Bless You
 
magneto664's Avatar
 
Industry Role:
Join Date: Aug 2014
Location: Glasgow, $cotland
Posts: 1,467
keep your server time & unix timestamp format to avoid people from time zone +12 or -12
__________________
magneto664 📧 gmail.com
Adult Backlinks 💘Best Website Stats 💘 Best CDN for Adult Content
My Fav: 👍Chaturbate 👍 Stripchat 👍 Dateprofits 👍 AdultFriendFinder
magneto664 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 07-25-2018, 02:49 AM   #4
freecartoonporn
Confirmed User
 
freecartoonporn's Avatar
 
Industry Role:
Join Date: Jan 2012
Location: NC
Posts: 7,683
Quote:
Originally Posted by redwhiteandblue View Post
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 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 07-25-2018, 02:52 AM   #5
freecartoonporn
Confirmed User
 
freecartoonporn's Avatar
 
Industry Role:
Join Date: Jan 2012
Location: NC
Posts: 7,683
Quote:
Originally Posted by magneto664 View Post
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 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 07-25-2018, 02:56 AM   #6
freecartoonporn
Confirmed User
 
freecartoonporn's Avatar
 
Industry Role:
Join Date: Jan 2012
Location: NC
Posts: 7,683
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
freecartoonporn is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 07-25-2018, 03:40 AM   #7
Klen
 
Klen's Avatar
 
Industry Role:
Join Date: Aug 2006
Location: Little Vienna
Posts: 32,235
Quote:
Originally Posted by freecartoonporn View Post
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" ?
Klen is online now   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks

Tags
delete, date, posts, format, choose, auto, expired, minute, cron, job, decide, save, time, logic, code, mysqlf, timestamp, post_creation_date, post_expiration_date, datetime, unix, pics, upload, expire, future



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.