Stashing limit/offset query values before performing total pagination count

Some database engines return zero, when using the count aggregate on a query with limit and offset. Just followed the same pattern for stashing the 'orders' clause before performing a count on the query, and adding back to the query when done.