zero_ZX Posted November 8, 2011 Share Posted November 8, 2011 Hi, The main idea is that I have a client running on certain desktops. Each 5th minute the client sends and update to the web-server, increasing "tick" by one. Tick start out as 0, so after 5 minutes ticket should be greater than 5. If tick is not greater than 0 then do <code omitted> I Guess I would need some kind of cronjob to complete this, but i'd love to avoid sessions & cookies at all costs, as the same server is checking the same tick but for different accounts.. Any suggestions are highly appreciated ^.^ Quote Link to comment https://forums.phpfreaks.com/topic/250739-comparing-old-value-to-new-value/ Share on other sites More sharing options...
requinix Posted November 8, 2011 Share Posted November 8, 2011 as the same server is checking the same tick but for different accounts.. So each update includes account information? Keep a table in your database with an account identifier and tick count. SELECT when you get the tick, optionally do your stuff, and UPDATE when done. No cronjobs needed because you already have a script running when each update is received. Quote Link to comment https://forums.phpfreaks.com/topic/250739-comparing-old-value-to-new-value/#findComment-1286426 Share on other sites More sharing options...
zero_ZX Posted November 8, 2011 Author Share Posted November 8, 2011 Guess I wasn't clear enough, Ill try to elaborate: As long as the client is running it's updating the tick with one. Let's say I close the application and it stops at 30. Next time the cron job calls the page it sees that it's 30 like last time, then it resets the tick to 0 and do some additional stuff. So the main issue is that I want to do something when the script is not running. Quote Link to comment https://forums.phpfreaks.com/topic/250739-comparing-old-value-to-new-value/#findComment-1286435 Share on other sites More sharing options...
xyph Posted November 9, 2011 Share Posted November 9, 2011 My advice would be to store two column for the ticks. One that gets updated by the client, the other gets updated by the CRON script checking. Every time the CRON executes, check if Column1 = Column2 (no ticks have been added since the last execution), and set to 0, otherwise set Column2 to Column1 That can be done in a single query. UPDATE `ticks` SET `user_ticks` = IF(`user_ticks` = `last_ticks`, 0, `user_ticks`), `last_ticks` = `user_ticks` Where user_ticks is the ticks sent by the user, and last_ticks is the last ticks counted by the CRON. Quote Link to comment https://forums.phpfreaks.com/topic/250739-comparing-old-value-to-new-value/#findComment-1286452 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.