Collections functions
General functions
Node functions
Render functions
Theme permission functions
User 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 25th April 2024 19:35 Europe/London time based on the source file dated 4th April 2024 10:05 Europe/London time.