Get all models in ActiveDataProvider

Hi,

Is there a way to get all the models from a ActiveDataProvider ? getModels() returns only the models in the current page even when i set setPagination() to false.

I’m trying to use spout to export my data to a Excel file but only the current page get exported.




$dataProvider->setPagination(false);

$writer = WriterFactory::create(Type::XLSX);

$writer->openToFile('azert.xlsx');

$xx = $dataProvider->getModels();

foreach ($xx as $N_xx) {

   $writer->addRow($N_xx->attributes);

}

$writer->close();



Thanks.

Why complicate things with a dataprovider?


$xx = \app\models\MyModel::find()->all();

Or, for a (possibly) large resultset:

http://www.yiiframework.com/doc-2.0/yii-db-query.html#each()-detail

Thanks.

I already did a similar thing (execute the query in the controller and pass it to the view) but I wanted to use the same data and was just curious why it didn’t work.