Revision: 11907
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at February 23, 2009 11:27 by cori
Initial Code
$x = ceil( substr( date( "i" ), 1, 1) / 2 ); //get number from 1 to 5 $min = ( 20 * ( $x - 1 ) ) + 1; //gets 1, 21, 41, 61, 81 $max = ( 20 * $x ); //gets 20, 40, 60, 80, 100 $feedListSql = quotesmart( "SELECT DISTINCT id, feed_url FROM {$this->feedTable} WHERE active = 1 AND id >= {$min} AND id <= {$max}" );
Initial URL
Initial Description
I needed to have a cron job that did some MySQL work iterating through a long list of items based on the content of a table in MySQL. I wanted each item in the table to be iterated over roughly once every 5 minutes, but building up the in-memory list of items to be processed based on the full contents of the table (~100 rows) was killing server memory and the process was dying. I wanted to find a way to, based on the time, only process a segment of the table's results, and to be reasonable confident that they would all be processed approximately every 5 minutes. Really simple problem, actually, but it took me a while to find the right logic...
Initial Title
list->mysql query iteration for cron job
Initial Tags
mysql
Initial Language
PHP