how to count $dataProvider items

yii
if412010 picture if412010 · Jan 20, 2014 · Viewed 26.4k times · Source

how can i count data that will retrieved by $dataProvider ? i've tried to use this code,

       $dataProvider = new CActiveDataProvider('Model');
       $dataProvider->totalItemCount;

Answer

ishtiaq ahmed picture ishtiaq ahmed · Feb 5, 2015

In yii2

For total count use

$dataProvider->getTotalCount()

For page count then

$dataProvider->getCount()

Refrence page http://www.yiiframework.com/doc-2.0/yii-data-basedataprovider.html#getTotalCount()-detail