Yii Framework Forum: paginating model, get count() - Yii Framework Forum

Jump to content

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

paginating model, get count() Rate Topic: -----

#1 User is offline   dimis283 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 277
  • Joined: 24-January 09

Posted 25 February 2010 - 08:25 AM

I have this code (Yii paging), how can I get the number of total records fetched?
$criteria=new CDbCriteria;        
        $criteria->order='date_date DESC';        
        $criteria->condition=' date_date=:time1';
        $month = date('n', $_GET['time']);        
        $year = date('Y', $_GET['time']);
        $day = date('d', $_GET['time']);
        if ($_GET['pnc'] == 'n') $month++;
        if ($_GET['pnc'] == 'p') $month--;
        $criteria->params[':time1']=  "$year-$month-$day";        
        
        $pages=new CPagination(calendars::model()->count($criteria));
        $pages->pageSize=20;
        $pages->applyLimit($criteria);
        
        $posts=calendars::model()->findAll($criteria);

Posted Image
0

#2 User is offline   wyldie 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 29
  • Joined: 22-May 09

Posted 25 February 2010 - 10:01 AM

should be $pages->itemCount

http://www.yiiframew...api/CPagination
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