how to find distinct values in array?

Hey everyone,

I would like to display something like:

Group 1 Header

data for group 1

Group 2 Header

data for group 2

Applying the distinct to the SQL query would leave me without detailed data. So, is there a function in Yii like


to extract the distinct values after the query?

As an alternative only a 2nd query comes into my mind :frowning:

Sorry. I’m mistaken

for distinct use




[s]for group see



try this

in the controler


and in the view

<?php foreach($models as $model):?>


     <?php foreach($model->detail as $detail):?>