jjmusicpro Posted December 20, 2008 Share Posted December 20, 2008 I have a program that checks the inputs of a form. IN the database i input a time/date stamp of when these took place, plus the IP they came from. I dont want someone to do more then 3 requets and hour. Can I check the amout of records using a SQL query? or do i have to do it in code. I know i can check a day range, but neve tried hours. Link to comment https://forums.phpfreaks.com/topic/137787-get-mysql-records-in-last-hour/ Share on other sites More sharing options...
jonsjava Posted December 20, 2008 Share Posted December 20, 2008 you could add a row to the user table, that keeps track of times someone ran queries, and when they hit 3 in the last 60 minutes, it cuts them off until one hour since first query. It would require a cron running every 1 or 5 minutes (a maintenance script to clean out out holds older than an hour). I'm being vague, sry. If you want help, feel free to ask. Link to comment https://forums.phpfreaks.com/topic/137787-get-mysql-records-in-last-hour/#findComment-720164 Share on other sites More sharing options...
jjmusicpro Posted December 20, 2008 Author Share Posted December 20, 2008 well i can get both the dates fine, i just dont know the syntax to check a range of "time" and count the mount of records. Ive done it for days, but not for hours Link to comment https://forums.phpfreaks.com/topic/137787-get-mysql-records-in-last-hour/#findComment-720168 Share on other sites More sharing options...
redarrow Posted December 20, 2008 Share Posted December 20, 2008 url http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html mysql> SELECT '2008-12-31 23:59:59' + INTERVAL 1 SECOND; -> '2009-01-01 00:00:00' mysql> SELECT INTERVAL 1 DAY + '2008-12-31'; -> '2009-01-01' mysql> SELECT '2005-01-01' - INTERVAL 1 SECOND; -> '2004-12-31 23:59:59' mysql> SELECT DATE_ADD('2000-12-31 23:59:59', -> INTERVAL 1 SECOND); -> '2001-01-01 00:00:00' mysql> SELECT DATE_ADD('2010-12-31 23:59:59', -> INTERVAL 1 DAY); -> '2011-01-01 23:59:59' mysql> SELECT DATE_ADD('2100-12-31 23:59:59', -> INTERVAL '1:1' MINUTE_SECOND); -> '2101-01-01 00:01:00' mysql> SELECT DATE_SUB('2005-01-01 00:00:00', -> INTERVAL '1 1:1:1' DAY_SECOND); -> '2004-12-30 22:58:59' mysql> SELECT DATE_ADD('1900-01-01 00:00:00', -> INTERVAL '-1 10' DAY_HOUR); -> '1899-12-30 14:00:00' mysql> SELECT DATE_SUB('1998-01-02', INTERVAL 31 DAY); -> '1997-12-02' mysql> SELECT DATE_ADD('1992-12-31 23:59:59.000002', -> INTERVAL '1.999999' SECOND_MICROSECOND); -> '1993-01-01 00:00:01.000001' Link to comment https://forums.phpfreaks.com/topic/137787-get-mysql-records-in-last-hour/#findComment-720171 Share on other sites More sharing options...
jjmusicpro Posted December 20, 2008 Author Share Posted December 20, 2008 sorry that dosent help, ive looked at that. do i have to compare dates first, then compare time? Link to comment https://forums.phpfreaks.com/topic/137787-get-mysql-records-in-last-hour/#findComment-720175 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.