php-crud-api icon indicating copy to clipboard operation
php-crud-api copied to clipboard

Add X-Total-Count header

Open Niek opened this issue 5 years ago • 2 comments

It would be great if the (kind of standardized) X-Total-Count response header could be added to API responses. This would make integration with for example react-admin easy.

Niek avatar Jan 21 '20 10:01 Niek

The easiest way to add this (without adding an extra SQL query when limits are applied) is to use window functions. This works on MySQL 8+, MariaDB 10.2+, PostgreSQL 9.4+ and MSSQL. Or use the good old SQL_CALC_FOUND_ROWS, but that is MySQL/MariaDB-specific.

Niek avatar Jan 28 '20 15:01 Niek

Can getResultSize() line 10179 be used to for the generation of the header, PHP without the need for additional SQL query?

garrettcam avatar Dec 15 '20 10:12 garrettcam