Monday, May 2, 2011

Re: Issue with getNumRows

This isn't a CakePHP bug. The Model::getNumRows() function returns the
number of rows returned in the last query. Since you are using the
limit clause, the number of rows in the query is less than or equal to
the limit (10 rows in your example). To get the actual number of rows
that could be returned based on your conditions, you should execute
find('count') without the limit clause.

CakePHP's built-in pagination automates this for you, and provides
additional functionality. Is there a reason you need to implement
your own pagination?

On May 2, 12:52 pm, jairis...@gmail.com wrote:
> Nobody has any idea about this?
>
> Rishab
> Sent from BlackBerry® on Airtel
>
>
>
> -----Original Message-----
> From: jairis...@gmail.com
> Date: Mon, 2 May 2011 14:41:24
> To: cake-php<cake-php@googlegroups.com>
>
> Reply-To: jairis...@gmail.com
> Subject: Issue with getNumRows
>
> Hi all,
>
> I am working on my own pagination in my setup. It works on 3 variables:
> 1. Page no requested.
> 2. Number of records to be shown on each page
> 3. Total records for that particular where condition.
>
> Now, the first point is taken runtime. The second point is pre-decided. The third point is what I use getNumRow() function. The problem is the number this function returns.
>
> For eg, if there are 40 records on result of any where condition. And we show 10 rows per page. Then, on page one the limit clause will be 0,10. For page 2, it will be 10,10. And 20,10 and 30,10 for the rest. But, to calculate this I need to execute the getNumRows() function on each request. But when I do that, I get 10 as the result of that function. Though, the expected result which normally mysql returns for SQL_CALC_FOUND_ROWS is '40'.
>
> Can anybody help me fixing this cakephp bug?
>
> Rishab
> Sent from BlackBerry® on Airtel

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate