yii\data\ActiveDataProvider::prepareModels PHP Method

prepareModels() protected method

protected prepareModels ( )
    protected function prepareModels()
    {
        if (!$this->query instanceof QueryInterface) {
            throw new InvalidConfigException('The "query" property must be an instance of a class that implements the QueryInterface e.g. yii\\db\\Query or its subclasses.');
        }
        $query = clone $this->query;
        if (($pagination = $this->getPagination()) !== false) {
            $pagination->totalCount = $this->getTotalCount();
            $query->limit($pagination->getLimit())->offset($pagination->getOffset());
        }
        if (($sort = $this->getSort()) !== false) {
            $query->addOrderBy($sort->getOrders());
        }
        return $query->all($this->db);
    }

Usage Example

Example #1
0
 protected function prepareModels()
 {
     if ($refinerSet = $this->getRefinerSet()) {
         $refinerSet->applyTo($this->query);
     }
     return parent::prepareModels();
 }
All Usage Examples Of yii\data\ActiveDataProvider::prepareModels