Reputation: 155
I use ActiveDateProvider and I use query like this:
Foo::find()->joinWith('relation');
And Foo's relation is hasMany, so there is more than one record joined to every Foo.
In that case the pagination doesn't work properly (for example in GridView it says: Showing 1-6 of 17 items. even though the pagination is set to 10 and there are actually only 10 records of Foo in the database)
What can I do to make the pagination work properly (counting only Foo, not the joined records)
Upvotes: 0
Views: 657
Reputation: 5954
Sorry for late reply, but I recently stuck into the issue and found out that distinct()
will do the trick for you.
Foo::find()->joinWith('relation')->distinct();
Upvotes: 0