Yii Framework Forum

Dataprovider - filter and count items - yii framework


(leroxx) #1

Hello,

can anyone tell me, how I can filter my dataprovider?

I have an dataprovider object with round about 1000 items with attributes like name, startdate, enddate, status, … There could be some entries for one name. I want to count the items to one name, get the average of startdate - enddate (of all items) and want to display it in a gridview like:

name | average time | count

But I don’t know how I can filter my dataprovider. Thanks in advance!


(Softark) #2

Could you show us the involved models (and db tables)?


(Alirz23) #3

docs are pretty comprehensive please take look at the following section of active record guides

https://www.yiiframework.com/doc/guide/2.0/en/output-data-providers#active-data-provider