Hey guys!
So I've stumbled on a little problem here, or I'm kinda clueless how to achieve it at all.
I'm currently working on a site which will have a premium feature, and they will pay for the features either monthly,annually or yearly. So i realized i have no freakin' idea how to achieve this the most efficient way.
So i got a table named Users
-- Users
-ID
-Username
-Password
-Expires(Date)
-Status(0 or 1(Where 1 = premium)
So i want to check if the expiry date in Expires table have passed, if it has i want it to change Status to zero, and im clueless how to do it.
Any pointers would be awesome i'm sitting here completely clueless.
XoXo,
Rivve
3 Replies - 133 Views - Last Post: 08 January 2013 - 05:36 PM
#1
Check if date have passed if so change user access
Posted 08 January 2013 - 03:08 PM
Replies To: Check if date have passed if so change user access
#2
Re: Check if date have passed if so change user access
Posted 08 January 2013 - 03:17 PM
If you are able to check the login you are able to query the database, right? Why not bring back the expiration date and do a compare against today's date? Or compare it against today's date in the query and if the bit says it is invalid then do an update on the status to make it not premium.
#3
Re: Check if date have passed if so change user access
Posted 08 January 2013 - 03:25 PM
modi123_1, on 08 January 2013 - 03:17 PM, said:
If you are able to check the login you are able to query the database, right? Why not bring back the expiration date and do a compare against today's date? Or compare it against today's date in the query and if the bit says it is invalid then do an update on the status to make it not premium.
Yeah that made alot of sense, guess i just needed to get it written out for me. Haven't slept in a while almost midnight here aswell so. Alright i'll be getting some work done again then!
Thanks alot, sorry for wasting your time!
#4
Re: Check if date have passed if so change user access
Posted 08 January 2013 - 05:36 PM
There is really no reason to have the "status" field at all. If you have the expiration date in the database, you can easily determine the status in your queries by comparing it to the current date. All you are doing by storing the "status" is creating the need to update the table when the date expires. - If you are concerned about performance, then don't be. Assuming you use proper date/time field types, a comparison like this is trivial.
Also, on a side-note. You should really try to be more explicit with your names. Using "status" as the name for a Boolean field is extremely unhelpful. You may know it's the status of the premium subscriptions, but it's not at all clear to anybody else. (Or even to you, if you were to come back to this project after a significant break.) - Something like "has_premium" would be better. (I like using "has" or "is" as the start of Boolean fields, but that's just me.)
Also, on a side-note. You should really try to be more explicit with your names. Using "status" as the name for a Boolean field is extremely unhelpful. You may know it's the status of the premium subscriptions, but it's not at all clear to anybody else. (Or even to you, if you were to come back to this project after a significant break.) - Something like "has_premium" would be better. (I like using "has" or "is" as the start of Boolean fields, but that's just me.)
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote







|