It required two parts to be done and I was able to fix the first part (please see comments on bug). However, while working on the second part which requires a set of page numbers to be generated while listing the pagination, I was able to do most of it except how to get the upper limit of page numbers.
I figured, this will require a query on the table to get total number of results in it. However the QueryPage::reallyDoQuery() function takes input the limit and the offset value only. I tried to do something like "SQL_CALC_FOUND_ROWS" but was not able to figure out how to implement this. Please give some suggestions.
Thanks.