Suppose I now have a table, where one column has a Time field, and I set it to expire in 2015-11-20.
I can write a logical judgment through the MySQL statement, when the server date equals the expiry time, delete the field, can I implement this function?
I now think of the use of MySQL dynamic execution process, but I think this logic for the MySQL server is not good, will produce performance problems, because the general logic of the judgment is implemented through the programming language.
I have to deal with the business logic is-I give my site's member users set a time permission to a certain date, when the member users enter my site, using a script to compare the server current date and I set the expiration date, if expired, delete the user, but it is not very good to write, So I want to use MySQL to judge the time field of the user periodically, and perform the task of deleting user data.
Would like to invite friends to point twos: This can be achieved? What's the impact of doing this?
Reply content:
Suppose I now have a table, where one column has a Time field, and I set it to expire in 2015-11-20.
I can write a logical judgment through the MySQL statement, when the server date equals the expiry time, delete the field, can I implement this function?
I now think of the use of MySQL dynamic execution process, but I think this logic for the MySQL server is not good, will produce performance problems, because the general logic of the judgment is implemented through the programming language.
I have to deal with the business logic is-I give my site's member users set a time permission to a certain date, when the member users enter my site, using a script to compare the server current date and I set the expiration date, if expired, delete the user, but it is not very good to write, So I want to use MySQL to judge the time field of the user periodically, and perform the task of deleting user data.
Would like to invite friends to point twos: This can be achieved? What's the impact of doing this?
Do you want to delete the record or delete the table or change the table structure?
If you delete a record, you can write a script in PHP or shell to check the expiration time, and then remove it.
Scripts can be placed inside the crontab and run once a day.