Reputation: 3923
I have in my database:
id | text | date
1 | sdsd | 2012-01-23 08:11:00
2 | asd | 2012-01-23 08:24:00
3 | dfdf | 2012-01-23 08:34:00
4 | fdf | 2012-01-23 08:41:00
5 | xcvx | 2012-01-23 08:48:00
etc
on my server is cron with 10 minutes intervals, for example:
08:03:00
08:13:00
08:23:00
08:33:00
08:43:00
08:53:00
how is the best method for get this values from databases with SQL for PHP?
Upvotes: 0
Views: 453
Reputation: 272276
This query will return all rows that have date
> last 10 minutes:
SELECT *
FROM `table`
WHERE `date` > CURRENT_TIMESTAMP - INTERVAL 10 MINUTE
It is assumed that your table does not contain any future dates.
Upvotes: 1
Reputation: 151674
In your cron script you could do something like this:
$res = mysql_query('select * from table where `date` < now()');
Then you simply do the thing you want to do with those rows.
Upvotes: 1
Reputation: 37516
Do a SQL query which looks for a time in the date field that is plus or minus 4 minutes of the current time according to PHP.
Upvotes: 1