When counting the total number of results, remove the "ORDER BY" clause if present.
Merge pull request #101 from snotling/master

Pagination count() query should remove ORDER BY clause(s)