seb hughes Posted May 18, 2007 Share Posted May 18, 2007 On some sites some stats are only updated every hour. I was wondering how this is done, because the query still shows the data, but only gets updated every x hours, how is this done. Quote Link to comment https://forums.phpfreaks.com/topic/52027-mysql-update-every-x-hours/ Share on other sites More sharing options...
effigy Posted May 18, 2007 Share Posted May 18, 2007 Timing events--such as imports/updates--is done with the OS: cron on Unix, and services on Windows. Quote Link to comment https://forums.phpfreaks.com/topic/52027-mysql-update-every-x-hours/#findComment-256432 Share on other sites More sharing options...
seb hughes Posted May 18, 2007 Author Share Posted May 18, 2007 The thing is for example, on youtube.com video views are update every hour, when you view a video, you see the plays, so it must be getting it from the database, but only change every hour. so it might be done with a cronjob, btu how do they get it to still display data btu not update for x hours. Quote Link to comment https://forums.phpfreaks.com/topic/52027-mysql-update-every-x-hours/#findComment-256441 Share on other sites More sharing options...
effigy Posted May 18, 2007 Share Posted May 18, 2007 Use SQL. The following will give you all records whose date_field entries are within the hour. SELECT * FROM table WHERE date_field >= DATE_SUB(NOW(), INTERVAL 1 HOUR) Quote Link to comment https://forums.phpfreaks.com/topic/52027-mysql-update-every-x-hours/#findComment-256457 Share on other sites More sharing options...
seb hughes Posted May 18, 2007 Author Share Posted May 18, 2007 Use SQL. The following will give you all records whose date_field entries are within the hour. SELECT * FROM table WHERE date_field >= DATE_SUB(NOW(), INTERVAL 1 HOUR) would this work with any prevous entries, eg 3 days ago, or 4 hours ago? Quote Link to comment https://forums.phpfreaks.com/topic/52027-mysql-update-every-x-hours/#findComment-256459 Share on other sites More sharing options...
effigy Posted May 18, 2007 Share Posted May 18, 2007 Yes. See the stuff about INTERVAL under DATE_ADD here. Quote Link to comment https://forums.phpfreaks.com/topic/52027-mysql-update-every-x-hours/#findComment-256503 Share on other sites More sharing options...
bubblegum.anarchy Posted May 18, 2007 Share Posted May 18, 2007 I recently learnt from fenway that mysql 5.1 has an inbuilt event scheduler: http://dev.mysql.com/doc/refman/5.1/en/events.html Quote Link to comment https://forums.phpfreaks.com/topic/52027-mysql-update-every-x-hours/#findComment-256709 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.