php-crud-api
php-crud-api copied to clipboard
Add X-Total-Count header
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.
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.
Can getResultSize() line 10179 be used to for the generation of the header, PHP without the need for additional SQL query?