Collections functions
General functions
Render functions
Theme permission functions
Resource functions

sql_limit_with_total_count()

Description

Utility function to obtain the total found rows while paginating the results.

IMPORTANT: the input query MUST have a deterministic order so it can help with performance and not have an undefined behaviour

configuration option (e.g $default_perpage, $default_perpage_list).

- total: int - count of total found records (before paging)
- data: array - paged result set

Parameters

ColumnTypeDefaultDescription
$query PreparedStatementQuery SQL query
$rows null|int Specifies the maximum number of rows to return. Usually set by a global
$offset null|int Specifies the offset of the first row to return. Use NULL to not offset.
$cachecount bool false Use previously cached count if available?
$countquery null|PreparedStatementQuery NULL Optional separate query to obtain count, usually without ORDER BY

Return

array Returns a:

This article was last updated 26th September 2022 12:35 Europe/London time based on the source file dated 14th September 2022 14:00 Europe/London time.