How to make something expire after certain months in db?

-2

I want to add a "license" to a purchase in my database, plus that license that my "customer" will buy will have an expiration time, let's say he bought a license ...

    INSERT INTO compras (userid, pluginid) VALUES ('$userid', '$pluginid');

Now, I want to make this INSERT that I made go away in 1 month, for example, how do I do this ??

    
asked by anonymous 01.06.2016 / 20:15

2 answers

2

Do not make this deletion, create a VALUE_DATA column, in the test application something like

select *
from compras
where userid = 'DaviDEV'
and   CURDATE() <= DATA_DE_VALIDADE

The advantage is that you do not lose information by even allowing you to "run behind" the customer for a return.

    
01.06.2016 / 20:22
3

Take a look at in this answer .

now() + INTERVAL 3 DAY

While NOW returns the current date and time, INTERVAL adds a time interval, see the manual: link

    
01.06.2016 / 20:22