yii\data\DataProviderInterface::getTotalCount PHP Method

getTotalCount() public method

When [[getPagination|pagination]] is false, this is the same as [[getCount|count]].
public getTotalCount ( ) : integer
return integer total number of possible data models.
    public function getTotalCount();

Usage Example

Beispiel #1
0
 /**
  * Serializes a data provider.
  * @param DataProviderInterface $dataProvider
  * @return array the array representation of the data provider.
  */
 protected function serializeDataProvider($dataProvider)
 {
     $models = $this->serializeModels($dataProvider->getModels());
     if ($dataProvider->getPagination() === false) {
         return $models;
     } else {
         return ['total' => $dataProvider->getTotalCount(), 'rows' => $models];
     }
 }