Thursday, 15 July 2010

mysql - Getting the total amount of results in a paginated query -


In my ROR app, I have a query that can remove 0 to 1000000 results anywhere, that I limited to 16 Provide pagination for and page:

  find (all: conditions => conditions, limit = & gt; limit, offset = & gt; offset)  

I can tell the user how many results they are versus watching. What is the best way to get the total amount of rows without doing some non-limited queries such as the total amount of the result showing "500 of something", which will definitely slow down in the case of big results? I would like to remain a database atheist.

It would appear that I should have used Google something more well In order to calculate a practical database of railways, a class (going to shape) has been made. I've wound up using code like this:

  result = get (all :: conditions => conditions, limit => limit, offset = & gt; offset ) Total_count = count (: terms = & gt; conditions) return {: results = & gt; Result, total_count = & gt; Total_count}  

No comments:

Post a Comment