Voodoo Jai Posted July 7, 2008 Share Posted July 7, 2008 I have a table in a db that I want to delete the contents, re initialise the auto-increment and start inputting new data again at a particular time every day. Could someone point me in the right direction as to how this can be done if at all. VoodooJai Quote Link to comment Share on other sites More sharing options...
fenway Posted July 7, 2008 Share Posted July 7, 2008 You should be able to run TRUNCATE on a cron -- or use the 5.1 event scheudler. Quote Link to comment Share on other sites More sharing options...
Voodoo Jai Posted July 7, 2008 Author Share Posted July 7, 2008 Could you give me some more details as I cannt find details in google with cron as the search term. Quote Link to comment Share on other sites More sharing options...
fenway Posted July 9, 2008 Share Posted July 9, 2008 Could you give me some more details as I cannt find details in google with cron as the search term. That's impossible. Quote Link to comment Share on other sites More sharing options...
Voodoo Jai Posted July 9, 2008 Author Share Posted July 9, 2008 Fter many hours of searching I found this section of code: <?php MYSQL_CONNECT('localhost','database_username','database_password'); @mysql_select_db("database_name") or die(mysql_error()); $query="TRUNCATE xoops_session"; $query="ALTER TABLE table-name AUTO_INCREMENT =1"; mysql_query($query); mysql_close() ?> I want to specify a specific table within a db, so do I need to change TRUNCATE xoops_session into TRUNCATE db-table-name then how do I get it to run at a specific time of the day and Quote Link to comment Share on other sites More sharing options...
fenway Posted July 9, 2008 Share Posted July 9, 2008 You don't need to run the alter statement, truncate does that automatically. Quote Link to comment Share on other sites More sharing options...
Voodoo Jai Posted July 9, 2008 Author Share Posted July 9, 2008 Thats great thank you, I found a good explanation from this web site. http://www.thesitewizard.com/general/set-cron-job.shtml Most helpful as well as PHPFreaks Quote Link to comment 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.