original_string: public static function segmentedFetchAll($sql, $first, $last, $step, $params = array())
      {
          $result = array();
  
          if ($step > 0) {
              for ($i = $first; $i <= $last; $i += $step) {
                  $currentParams = array_merge($params, array($i, $i + $step));
                  $result        = array_merge($result, self::fetchAll($sql, $currentParams));
              }
          } else {
              for ($i = $first; $i >= $last; $i += $step) {
                  $currentParams = array_merge($params, array($i, $i + $step));
                  $result        = array_merge($result, self::fetchAll($sql, $currentParams));
              }
          }
  
          return $result;
      }
code: public static function segmentedFetchAll($sql, $first, $last, $step, $params = array())
      {
          $result = array();
  
          if ($step > 0) {
              for ($i = $first; $i <= $last; $i += $step) {
                  $currentParams = array_merge($params, array($i, $i + $step));
                  $result        = array_merge($result, self::fetchAll($sql, $currentParams));
              }
          } else {
              for ($i = $first; $i >= $last; $i += $step) {
                  $currentParams = array_merge($params, array($i, $i + $step));
                  $result        = array_merge($result, self::fetchAll($sql, $currentParams));
              }
          }
  
          return $result;
      }
code_tokens: public static function segmentedFetchAll ( $ sql , $ first , $ last , $ step , $ params = array ( ) ) { $ result = array ( ) ; if ( $ step > 0 ) { for ( $ i = $ first ; $ i <= $ last ; $ i += $ step ) { $ currentParams = array_merge ( $ params , array ( $ i , $ i + $ step ) ) ; $ result = array_merge ( $ result , self :: fetchAll ( $ sql , $ currentParams ) ) ; } } else { for ( $ i = $ first ; $ i >= $ last ; $ i += $ step ) { $ currentParams = array_merge ( $ params , array ( $ i , $ i + $ step ) ) ; $ result = array_merge ( $ result , self :: fetchAll ( $ sql , $ currentParams ) ) ; } } return $ result ; }
docstring: Performs a SELECT on a table one chunk at a time and returns an array
  of every fetched row.
  
  This function will break up a `SELECT` query into several smaller queries by
  using only a limited number of rows at a time. It will accumulate the results
  of each smaller query and return the result.
  
  This function should be used when performing a `SELECT` that can
  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)
  @return array An array of rows that includes the result set of every smaller
  query.
docstring_tokens: Performs a SELECT on a table one chunk at a time and returns an array of every fetched row .