How to seperate trial users with non trials based on time in mySQL/PHP
I know, the title does not sound good however I will explain it clearly. In mySQL table there is a column named expires
. It will hold a date in the future that will be checked against current time of the server every time a user logs in.
So, when that day is passed and the user logs in, he will get a message. There are two user roles, number 2 and number 3. Number 3 will never have an ending period. Number 2 have "trial" accounts.
I know how to set the value for users with role 2 and make the check against time() on logging, but what is the value I should place in column开发者_Go百科 expires
on users with role 3 and how can I make the check against time for them when logging? Maybe a time at 2020 does the trick but isn't it kind of silly ?
I would probably just store NULL
for the non-expiring accounts. When validating them, first test if the column value is null, in which case you have a type 3, then check if the date has passed, wherein you have an expired type 2.
You can save some programming on the application side if you stored it as a date far far in the future, but a NULL
makes more logical sense to me.
精彩评论