yii\data\BaseDataProvider::getTotalCount PHP Method

getTotalCount() public method

When [[pagination]] is false, this returns the same value as [[count]]. Otherwise, it will call BaseDataProvider::prepareTotalCount to get the count.
public getTotalCount ( ) : integer
return integer total number of possible data models.
    public function getTotalCount()
    {
        if ($this->getPagination() === false) {
            return $this->getCount();
        } elseif ($this->_totalCount === null) {
            $this->_totalCount = $this->prepareTotalCount();
        }
        return $this->_totalCount;
    }

Usage Example

 /**
  * Constructor.
  * @param BaseDataProvider $dataProvider the data provider to iterate over
  * @param integer $pageSize pageSize to use for iteration. This is the number of objects loaded into memory at the same time.
  */
 public function __construct(BaseDataProvider $dataProvider, $pageSize = null)
 {
     $this->_dataProvider = $dataProvider;
     $this->_totalItemCount = $dataProvider->getTotalCount();
     if (($pagination = $this->_dataProvider->getPagination()) === false) {
         $this->_dataProvider->setPagination($pagination = new Pagination());
     }
     if ($pageSize !== null) {
         $pagination->pageSize = $pageSize;
     }
 }
All Usage Examples Of yii\data\BaseDataProvider::getTotalCount