Current location: Hot Scripts Forums » Programming Languages » PHP » auto delete records in Mysql


auto delete records in Mysql

Reply
  #1 (permalink)  
Old 07-16-05, 08:47 PM
Bazzio Bazzio is offline
Newbie Coder
 
Join Date: May 2004
Posts: 50
Thanks: 0
Thanked 0 Times in 0 Posts
auto delete records in Mysql

Hey
I have a gig guide on my site
the date is store as MM.DD.YY in event_date in MySQL table

when the date has past, i want to have the old gigs deleted automatically

Can anyone help me out??
Thanks!!
Andy
Reply With Quote
  #2 (permalink)  
Old 07-18-05, 02:16 AM
xtremenw xtremenw is offline
Newbie Coder
 
Join Date: Dec 2004
Location: Tacoma, WA
Posts: 69
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by Bazzio
Hey
I have a gig guide on my site
the date is store as MM.DD.YY in event_date in MySQL table

when the date has past, i want to have the old gigs deleted automatically

Can anyone help me out??
Thanks!!
Andy
Mysql does not have anything like that built it... The closest thing would be to build a stored procedure and a trigger... But that would only work in MySQL5... You could build a scheduled task (Windows) or a cron job (Unix) to just run the following query at 12:01am everyday. 'DELETE FROM $table WHERE date_stamp < NOW();'
Reply With Quote
  #3 (permalink)  
Old 07-18-05, 06:06 AM
Bazzio Bazzio is offline
Newbie Coder
 
Join Date: May 2004
Posts: 50
Thanks: 0
Thanked 0 Times in 0 Posts
is there a way i can use php to not display the dates that have passed instead?
Reply With Quote
  #4 (permalink)  
Old 07-18-05, 08:46 PM
xtremenw xtremenw is offline
Newbie Coder
 
Join Date: Dec 2004
Location: Tacoma, WA
Posts: 69
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by Bazzio
is there a way i can use php to not display the dates that have passed instead?
Absolutly! In your SQL statement, just include in the WHERE clause 'date_scheduled > curdate();'

Hope that helps...
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Useful MySQL Resources ptesone Database 30 02-23-11 08:28 AM
UPDATE: MySQL Auto Backup & Export v1.1 Beyonder General Advertisements 2 03-21-05 02:05 PM
Delete row from mysql error. bigkid PHP 1 08-05-04 09:36 PM
Excel document containing records, need to save as a text file to upload to mysql bearslife PHP 1 06-05-04 03:24 AM
mysql - auto deletion of records munricer Script Requests 0 10-05-03 03:21 PM


All times are GMT -5. The time now is 06:56 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.