4

I am trying to make a query to get the first 10 records for example, and pass it to the ActiveDataProvider.

The query is working fine and returning the required number of records only, while the ActiveDataProvider is printing all the records, here is my code:

    $query = new \yii\db\Query;
    $query->select('*')
            ->from('customers')
            ->limit(10);
    $query->createCommand();

    $dataProvider = new ActiveDataProvider([
        'query' => $query,
    ]);
Insane Skull
  • 8,810
  • 9
  • 38
  • 59
Mohammad
  • 3,053
  • 5
  • 46
  • 70

1 Answers1

7

Set Pagination to false :

$dataProvider = new ActiveDataProvider([
'pagination' => false
]);

Reference

Community
  • 1
  • 1
Insane Skull
  • 8,810
  • 9
  • 38
  • 59