Well I agree it might not be a bug, however, I really don't understand the
need to have execute a find('count) function again to fetch the total number
of rows. I'm not getting into pagination coz I've already built something
and don't have the time now to move on to the cake pagination. I just wanted
to know if there's another function just like getNumRows() which could
provide me with the total rows selected for that particular where clause.regards, Rishab On Tue, May 3, 2011 at 10:47 AM, ShadowCross <[email protected]> wrote: > 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, [email protected] wrote: > > Nobody has any idea about this? > > > > Rishab > > Sent from BlackBerry® on Airtel > > > > > > > > -----Original Message----- > > From: [email protected] > > Date: Mon, 2 May 2011 14:41:24 > > To: cake-php<[email protected]> > > > > Reply-To: [email protected] > > 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 > [email protected] For more options, visit this group > at http://groups.google.com/group/cake-php > -- 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 [email protected] For more options, visit this group at http://groups.google.com/group/cake-php
