This topic is locked

Delete record by date

3/23/2011 12:15:00 AM
PHPRunner General questions
C
copper21 author

Hello all,
I have looked all over and can not find a solution; I am sure it is an easy one. I am simply looking to delete a record by date. I am using Mysql with PHP Runner 5.3. I have one table with an "end_date" field. The table is not part of a parent/child relationship, just a simple table in a database. I want the record to be deleted when the day after the "end_date" arrives. So for example, if a date of 03/23/11 is entered as the "end_date", I want the record to be deleted on 03/24/11. I think I read in the manual that the delete function is not supported on the SQL query side of it; but I coult be wrong.
Thanks for your help!

Sergey Kornilov admin 3/23/2011

To execute some script automatically on timely fashion i.e. daily you need an external scheduler.
Here is the example of doing this:

http://www.asprunner.com/forums/topic/14793-sample-script-to-send-email-on-timely-fashion/
Instead of sending email you need to execute a SQL query that deletes old records.
Something like this:

include("include/dbcommon.php");

CustomQuery("delete from TableName where now()>=end_date");