var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Delete data after 1 month
I have form of uploading data to the database, but I need to delete data after 1 month. how does it possibe.
here is my query of insert data to the database:
Should I need to add fields for date upload?
$sql = "INSERT INTO sales_order (ProductType,WorkOrder,POIssueDate,SalesMonth)
ON DUPLICATE KEY UPDATE
ProductType = '$ProductType', WorkOrder = '$WorkOrder', POIssueDate = '$POIssueDate', SalesMonth = '$SalesMonth'" or die(mysql_error());
Unless you know the records that have been added today you will not know which ones should be removed 1 month from now. So you need to add a field to hold this information.
run a delete query (possibly as a cron job) that deletes based on comparing the current date to whatever date column(s) in your db
do the comparison using one of the datetime functions such as datesub
MySQL :: MySQL 5.5 Reference Manual :: 12.7 Date and Time Functions
I'd rather be riding on the Tiger 800 or the Norton
You can also use MySQL EVENTS which is an internal scheduler. But the problem is still do you know which records are added today or any day. I would suggest adding in a separate field which has a default of the current date. With this you can then identify the records that were added on whatever date and as such can remove all records based on date or age in the database.