public function getRecordIdBatches($batchSize = null, $filterLogic = null, $recordIdFieldName = null)
    {
        $recordIdBatches = array();
        
        #-----------------------------------
        # Check arguments
        #-----------------------------------
        if (!isset($batchSize)) {
            $message = 'The number of batches was not specified.';
            $this->errorHandler->throwException($message, ErrorHandlerInterface::INVALID_ARGUMENT);
        } elseif (!is_int($batchSize)) {
            $message = "The batch size argument has type '".gettype($batchSize).'", '
                .'but it should have type integer.';
                $this->errorHandler->throwException($message, ErrorHandlerInterface::INVALID_ARGUMENT);
        } elseif ($batchSize < 1) {
            $message = 'The batch size argument is less than 1. It needs to be at least 1.';
            $this->errorHandler->throwException($message, ErrorHandlerInterface::INVALID_ARGUMENT);
        } // @codeCoverageIgnore
        
        $filterLogic = $this->processFilterLogicArgument($filterLogic);
        
        if (!isset($recordIdFieldName)) {
            $recordIdFieldName = $this->getRecordIdFieldName();
        }
        
        $records = $this->exportRecordsAp(
            ['fields' => [$recordIdFieldName], 'filterLogic' => $filterLogic]
        );
        $recordIds = array_column($records, $recordIdFieldName);
        $recordIds = array_unique($recordIds);  # Remove duplicate record IDs
        
        $numberOfRecordIds = count($recordIds);
        
        $position = 0;
        for ($position = 0; $position < $numberOfRecordIds; $position += $batchSize) {
            $recordIdBatch = array();
            $recordIdBatch = array_slice($recordIds, $position, $batchSize);
            array_push($recordIdBatches, $recordIdBatch);
        }
        
        return $recordIdBatches;
    }
public function getRecordIdBatches($batchSize = null, $filterLogic = null, $recordIdFieldName = null)
    {
        $recordIdBatches = array();
        
        #-----------------------------------
        # Check arguments
        #-----------------------------------
        if (!isset($batchSize)) {
            $message = 'The number of batches was not specified.';
            $this->errorHandler->throwException($message, ErrorHandlerInterface::INVALID_ARGUMENT);
        } elseif (!is_int($batchSize)) {
            $message = "The batch size argument has type '".gettype($batchSize).'", '
                .'but it should have type integer.';
                $this->errorHandler->throwException($message, ErrorHandlerInterface::INVALID_ARGUMENT);
        } elseif ($batchSize < 1) {
            $message = 'The batch size argument is less than 1. It needs to be at least 1.';
            $this->errorHandler->throwException($message, ErrorHandlerInterface::INVALID_ARGUMENT);
        } // @codeCoverageIgnore
        
        $filterLogic = $this->processFilterLogicArgument($filterLogic);
        
        if (!isset($recordIdFieldName)) {
            $recordIdFieldName = $this->getRecordIdFieldName();
        }
        
        $records = $this->exportRecordsAp(
            ['fields' => [$recordIdFieldName], 'filterLogic' => $filterLogic]
        );
        $recordIds = array_column($records, $recordIdFieldName);
        $recordIds = array_unique($recordIds);  # Remove duplicate record IDs
        
        $numberOfRecordIds = count($recordIds);
        
        $position = 0;
        for ($position = 0; $position < $numberOfRecordIds; $position += $batchSize) {
            $recordIdBatch = array();
            $recordIdBatch = array_slice($recordIds, $position, $batchSize);
            array_push($recordIdBatches, $recordIdBatch);
        }
        
        return $recordIdBatches;
    }
public function getRecordIdBatches ( $ batchSize = null , $ filterLogic = null , $ recordIdFieldName = null ) { $ recordIdBatches = array ( ) ; #----------------------------------- # Check arguments #----------------------------------- if ( ! isset ( $ batchSize ) ) { $ message = 'The number of batches was not specified.' ; $ this -> errorHandler -> throwException ( $ message , ErrorHandlerInterface :: INVALID_ARGUMENT ) ; } elseif ( ! is_int ( $ batchSize ) ) { $ message = "The batch size argument has type '" . gettype ( $ batchSize ) . '", ' . 'but it should have type integer.' ; $ this -> errorHandler -> throwException ( $ message , ErrorHandlerInterface :: INVALID_ARGUMENT ) ; } elseif ( $ batchSize < 1 ) { $ message = 'The batch size argument is less than 1. It needs to be at least 1.' ; $ this -> errorHandler -> throwException ( $ message , ErrorHandlerInterface :: INVALID_ARGUMENT ) ; } // @codeCoverageIgnore $ filterLogic = $ this -> processFilterLogicArgument ( $ filterLogic ) ; if ( ! isset ( $ recordIdFieldName ) ) { $ recordIdFieldName = $ this -> getRecordIdFieldName ( ) ; } $ records = $ this -> exportRecordsAp ( [ 'fields' => [ $ recordIdFieldName ] , 'filterLogic' => $ filterLogic ] ) ; $ recordIds = array_column ( $ records , $ recordIdFieldName ) ; $ recordIds = array_unique ( $ recordIds ) ; # Remove duplicate record IDs $ numberOfRecordIds = count ( $ recordIds ) ; $ position = 0 ; for ( $ position = 0 ; $ position < $ numberOfRecordIds ; $ position += $ batchSize ) { $ recordIdBatch = array ( ) ; $ recordIdBatch = array_slice ( $ recordIds , $ position , $ batchSize ) ; array_push ( $ recordIdBatches , $ recordIdBatch ) ; } return $ recordIdBatches ; }
Gets an array of record ID batches.

These can be used for batch
processing of records exports to lessen memory requirements, for example:
<code>
...
# Get all the record IDs of the project in 10 batches
$recordIdBatches = $project->getRecordIdBatches(10);
foreach ($recordIdBatches as $recordIdBatch) {
$records = $project->exportRecordsAp(['recordIds' => $recordIdBatch]);
...
}
...
</code>

@param integer $batchSize the batch size in number of record IDs.
The last batch may have less record IDs. For example, if you had 500
record IDs and specified a batch size of 200, the first 2 batches would have
200 record IDs, and the last batch would have 100.
@param array $filterLogic logic used to restrict the records retrieved, e.g.,
"[last_name] = 'Smith'". This could be used for batch processing a subset
of the records.
@param $recordIdFieldName the name of the record ID field. Specifying this is not
necessary, but will speed things up, because it will eliminate the need for
this method to call the REDCap API to retrieve the value.
@return array an array or record ID arrays, where each record ID array
is considered to be a batch. Each batch can be used as the value
for the records IDs parameter for an export records method.
Gets an array of record ID batches .