unknown87 Posted November 16, 2008 Share Posted November 16, 2008 Hi I have a temporary database and permanent database and I want to move data from the temporary database to the permanent database in ID order. I want to move one row at a time every 5 minutes. How can I acheive this? This is what I have so far: SELECT id FROM temporary ORDER BY id LIMIT 1; INSERT INTO permanent SELECT * FROM temporary WHERE id = $id DELETE FROM temporary WHERE id = $id Thanks In Advance Quote Link to comment https://forums.phpfreaks.com/topic/132988-temporary-to-permanent-database/ Share on other sites More sharing options...
Mchl Posted November 16, 2008 Share Posted November 16, 2008 Do you have a possibility to run cron jobs on your server? Quote Link to comment https://forums.phpfreaks.com/topic/132988-temporary-to-permanent-database/#findComment-691617 Share on other sites More sharing options...
unknown87 Posted November 16, 2008 Author Share Posted November 16, 2008 no but i'm but looking to switch hosts which supports cron jobs in the near future. is there a way to acheive without using crons? Quote Link to comment https://forums.phpfreaks.com/topic/132988-temporary-to-permanent-database/#findComment-691621 Share on other sites More sharing options...
Mchl Posted November 16, 2008 Share Posted November 16, 2008 Not with PHP. Well.. you could trigger database operations whenever someone enters your site, but it would be dependent on your site traffic. Quote Link to comment https://forums.phpfreaks.com/topic/132988-temporary-to-permanent-database/#findComment-691641 Share on other sites More sharing options...
unknown87 Posted November 16, 2008 Author Share Posted November 16, 2008 I can't see that working for me. Is it possibe with javascript/ajax? Quote Link to comment https://forums.phpfreaks.com/topic/132988-temporary-to-permanent-database/#findComment-691655 Share on other sites More sharing options...
Mchl Posted November 16, 2008 Share Posted November 16, 2008 Now that you mention it... It possibly could... You'd have to have a webpage, that would send requests to a php script every 5 minutes... The problem would appear if you loose your internet connection (or switch your PC off) Quote Link to comment https://forums.phpfreaks.com/topic/132988-temporary-to-permanent-database/#findComment-691659 Share on other sites More sharing options...
Maq Posted November 17, 2008 Share Posted November 17, 2008 Yes you can. You should write a recursive function that performs the database operations. At the end just call sleep(300). Sleep delays execution, 300 is in seconds = 5 mins. Quote Link to comment https://forums.phpfreaks.com/topic/132988-temporary-to-permanent-database/#findComment-691756 Share on other sites More sharing options...
Mchl Posted November 17, 2008 Share Posted November 17, 2008 Recusive? I don't really know PHP internals, but most other languages use stack to keep track of recursion nesting. Making such function recursive will most likely crash the script sooner or later. If anything this could be done in an infinite while loop. Also time execution timer should be set up high enough and reset in each loop pass. Quote Link to comment https://forums.phpfreaks.com/topic/132988-temporary-to-permanent-database/#findComment-691896 Share on other sites More sharing options...
unknown87 Posted November 17, 2008 Author Share Posted November 17, 2008 how can I make this work with an infinite while loop - can anyone help me with this? thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/132988-temporary-to-permanent-database/#findComment-692191 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.