This topic is locked

Auto Delete the record after 10 days

11/7/2011 2:35:34 PM
PHPRunner General questions
author

I would like the record to be auto deleted after 10 days. I read somewhere I need cron to run this. is that still true with the ver 6?

M
mickna 11/7/2011

I believe PR has nothing to do at all with cron.
So yes. If you want do do this automatically on a regular manner you should set up a cron-job.

A cron-job is a "job" on your server, witch will do some actions (to be defined, here to delete some entries).
Imagine: No one is using your website for 14 days. No one is calling your site. So no script from PR will run for 14 days. No script can do a search and delete the entries, as the scripts are not running at all, if no one looks at your site.
However: If it is not necessary to delete entries after exactly xx days, I would include a routine in PR. Maybe in the admin-Section. Do a quick search, if users should be deleted and fire up a message for you (admin), or just delete them - as you like.

Sergey Kornilov admin 11/7/2011

Answering original question - you do need cron or any other external scheduler. This is the way how web applications work and mickna explained it nicely.
As a quick workaround you can simply limit your data to always show the last 10 days. Even if records are not deleted physically nobody will ever see them.

select ...

from table

where `datefield` >= DATE_SUB(CURDATE(), INTERVAL 10 DAY)
500501 11/7/2011



Answering original question - you do need cron or any other external scheduler. This is the way how web applications work and mickna explained it nicely.
As a quick workaround you can simply limit your data to always show the last 10 days. Even if records are not deleted physically nobody will ever see them.

select ...

from table

where `datefield` >= DATE_SUB(CURDATE(), INTERVAL 10 DAY)



I added (or tried to add)

WHERE date_added >= DATE_SUB(CURDATE(), INTERVAL 10 DAY)
to my sql query and I got an error message where did you mean to add this code?

Sergey Kornilov admin 11/7/2011

You need to add it to the SQL Query.
Full SQL Query and error message will be helpful.

500502 11/9/2011

The error says cannot retrieve column info... error in syntax

TIME is a set up as timestamp in the table.
SELECT

ID,

projectID,

senderemail,

projectname,

username,

password,

name,

email,

subject,

folder,

PrintID,

NOTES,

FOLDER_LINK,

DATESTAMP,

created,

TIME,

IP,

BROWSER,

active

WHERE TIME >= DATE_SUB(CURDATE(), INTERVAL 10 DAY)

FROM projects