Collections functions
General functions
Render functions
Theme permission functions
Resource functions



Allow $fetchrows as supplied to do_search() to support an integer or array. If integer then search will recieve the number of rows with no offset.
If array then search will receive the number of rows to return and an offset allowing for chunking of results.
$chunk_offset[0] is the offset of the first row to return. $chunk_offset[1] is the number of rows to return in the batch. $chunk_offset[0] will normally be 0 in the first search,
increasing by $chunk_offset[1] for each search, generated by an external looping structure. This allows for batches of $chunk_offset[1] search results up to the total size of the search.
For an example {@see pages/csv_export_results_metadata.php}. This approach can be used to avoid particularly large searches exceeding the PHP memory_limit when processing the data in ps_query().


$fetchrows int|array $fetchrows value passed from do_search() / search_special(). See details above.
&$chunk_offset ?int
&$search_chunk_size: ?int
$chunk_offset int Starting position for offset. Default is 0 if none supplied i.e. $fetchrows is int.
$search_chunk_size int Number of rows to return.




include/search_functions.php lines 3299 to 3311


function setup_search_chunks($fetchrows, ?int &$chunk_offset, ?int &$search_chunk_size): void
    if (
is_array($fetchrows) && isset($fetchrows[0]) && isset($fetchrows[1]))
$chunk_offset $fetchrows[0];
$search_chunk_size $fetchrows[1];
$chunk_offset 0;
$search_chunk_size $fetchrows;

This article was last updated 9th June 2023 18:35 Europe/London time based on the source file dated 8th June 2023 10:25 Europe/London time.