Yii Framework Forum: CActiveDataProvider avoiding getTotalItemCount - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

CActiveDataProvider avoiding getTotalItemCount Rate Topic: ***** 1 Votes

#1 User is offline   ema 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 11-June 11

Posted 03 April 2012 - 06:58 AM

As COUNT queries sometimes are heavy and unnecessary, I'd like to propose to not force the getTotalItemCount in CActiveDataProvider (see line 129).

Currently you can only avoid it if your ADP has no pagination. My proposal is to perform it only if the pagination object has not itemCount already set (e.g. at construction time):

CActiveDataProvider.php:129
+++ if(!$pagination->getItemCount())
$pagination->setItemCount($this->getTotalItemCount());

This allows for more flexibility in the definition of pagination object, e.g. for infinity-scroll-like paginations.
Best, E.
0

#2 User is offline   felipe_Brz 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 02-January 12
  • Location:Rio de Janeiro - Brazil

Posted 16 April 2012 - 10:10 PM

View Postema, on 03 April 2012 - 06:58 AM, said:

As COUNT queries sometimes are heavy and unnecessary, I'd like to propose to not force the getTotalItemCount in CActiveDataProvider (see line 129).

Currently you can only avoid it if your ADP has no pagination. My proposal is to perform it only if the pagination object has not itemCount already set (e.g. at construction time):

CActiveDataProvider.php:129
+++ if(!$pagination->getItemCount())
$pagination->setItemCount($this->getTotalItemCount());

This allows for more flexibility in the definition of pagination object, e.g. for infinity-scroll-like paginations.
Best, E.

great idea.. +1
0

#3 User is offline   pavlepredic 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 39
  • Joined: 30-August 11

Posted 09 May 2012 - 11:13 AM

Maybe you can call setTotalItemCount() before calling getData().
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users