public static function segmentedQuery($sql, $first, $last, $step, $params = array())
    {
        if ($step > 0) {
            for ($i = $first; $i <= $last; $i += $step) {
                $currentParams = array_merge($params, array($i, $i + $step));
                self::query($sql, $currentParams);
            }
        } else {
            for ($i = $first; $i >= $last; $i += $step) {
                $currentParams = array_merge($params, array($i, $i + $step));
                self::query($sql, $currentParams);
            }
        }
    }
public static function segmentedQuery($sql, $first, $last, $step, $params = array())
    {
        if ($step > 0) {
            for ($i = $first; $i <= $last; $i += $step) {
                $currentParams = array_merge($params, array($i, $i + $step));
                self::query($sql, $currentParams);
            }
        } else {
            for ($i = $first; $i >= $last; $i += $step) {
                $currentParams = array_merge($params, array($i, $i + $step));
                self::query($sql, $currentParams);
            }
        }
    }
public static function segmentedQuery ( $ sql , $ first , $ last , $ step , $ params = array ( ) ) { if ( $ step > 0 ) { for ( $ i = $ first ; $ i <= $ last ; $ i += $ step ) { $ currentParams = array_merge ( $ params , array ( $ i , $ i + $ step ) ) ; self :: query ( $ sql , $ currentParams ) ; } } else { for ( $ i = $ first ; $ i >= $ last ; $ i += $ step ) { $ currentParams = array_merge ( $ params , array ( $ i , $ i + $ step ) ) ; self :: query ( $ sql , $ currentParams ) ; } } }
Performs a `UPDATE` or `DELETE` statement on a table one chunk at a time.

This function will break up a query into several smaller queries by
using only a limited number of rows at a time.

This function should be used when executing a non-query statement will
take a long time to finish. Using several smaller queries will ensure that
the table will not be locked for too long.

@param string $sql The SQL to perform. The last two conditions of the `WHERE`
expression must be as follows: `'id >= ? AND id < ?'` where
**id** is the int id of the table.
@param int $first The minimum ID to loop from.
@param int $last The maximum ID to loop to.
@param int $step The maximum number of rows to scan in one query.
@param array $params Parameters to bind in the query, `array(param1 => value1, param2 => value2)`
Performs a UPDATE or DELETE statement on a table one chunk at a time .