drakecai Posted October 8, 2010 Share Posted October 8, 2010 Is there anyway I can make mysql delete the information i entered from php everyday? or every few hours? I want it to do it without any human supervision. Quote Link to comment https://forums.phpfreaks.com/topic/215392-make-mysql-delete-information-daily/ Share on other sites More sharing options...
BlueSkyIS Posted October 8, 2010 Share Posted October 8, 2010 you need crontab. google it. you can use it to run a PHP script to delete or whatever you need. Quote Link to comment https://forums.phpfreaks.com/topic/215392-make-mysql-delete-information-daily/#findComment-1120070 Share on other sites More sharing options...
trq Posted October 8, 2010 Share Posted October 8, 2010 Depending on your MySql version you may also be able to use the built in scheduled events. See http://dev.mysql.com/doc/refman/5.1/en/events-overview.html Quote Link to comment https://forums.phpfreaks.com/topic/215392-make-mysql-delete-information-daily/#findComment-1120074 Share on other sites More sharing options...
drakecai Posted October 8, 2010 Author Share Posted October 8, 2010 is there an alternative? I tried and it works for my remote computer but when I tried implementing that same code into godaddy's phpmyadmin it gave me an error. Also for the one that worked it kept on telling me that "this value is not allowed" whether i put 1, a or null i'm trying to get mysql to drop a table every 24 hours at 12:00 and then recreate the table fresh without data inside the table at 12:01 any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/215392-make-mysql-delete-information-daily/#findComment-1120109 Share on other sites More sharing options...
fenway Posted October 8, 2010 Share Posted October 8, 2010 Well, something has to run code on a schedule -- either mysql or the kernel, your choice. Quote Link to comment https://forums.phpfreaks.com/topic/215392-make-mysql-delete-information-daily/#findComment-1120211 Share on other sites More sharing options...
drakecai Posted October 8, 2010 Author Share Posted October 8, 2010 Well I decided to use mysql/phpmyadmin. Can someone give me the code for event scheduling? For... clearing a table of all of its data everyday at 3 am Quote Link to comment https://forums.phpfreaks.com/topic/215392-make-mysql-delete-information-daily/#findComment-1120427 Share on other sites More sharing options...
BlueSkyIS Posted October 9, 2010 Share Posted October 9, 2010 i have never used MySQL event scheduling. here is the manual page for creating a new event: http://dev.mysql.com/doc/refman/5.1/en/create-event.html the first thing that jumps out at me is this: The event will not run unless the Event Scheduler is enabled. Whether or not that is enabled might be a question for your web host. Quote Link to comment https://forums.phpfreaks.com/topic/215392-make-mysql-delete-information-daily/#findComment-1120432 Share on other sites More sharing options...
BlueSkyIS Posted October 9, 2010 Share Posted October 9, 2010 Also: you can use TRUNCATE TABLE table_name to empty a table and reset any auto-incrementing values to 0. This is more efficient than dropping and re-creating the table. Quote Link to comment https://forums.phpfreaks.com/topic/215392-make-mysql-delete-information-daily/#findComment-1120433 Share on other sites More sharing options...
drakecai Posted October 9, 2010 Author Share Posted October 9, 2010 Thanks I just recently found that out, can someone give me the crontab code to clear out my table? Godaddy only needs me to upload a file, it already sets for the me the time to run and the frequency to run it. Quote Link to comment https://forums.phpfreaks.com/topic/215392-make-mysql-delete-information-daily/#findComment-1120493 Share on other sites More sharing options...
fenway Posted October 10, 2010 Share Posted October 10, 2010 Thanks I just recently found that out, can someone give me the crontab code to clear out my table? That question doesn't make any sense. There is no such thing as "crontab code" -- you just indicate which executable you'd like it to run a given interval. That executable is likely a php script that runs whatever code you would normally run to do this work. Quote Link to comment https://forums.phpfreaks.com/topic/215392-make-mysql-delete-information-daily/#findComment-1120797 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.