In yii2 how to select unique values from a database?

Necessary to choose values for 2 fields (E.g. code and name), the lines where the field "code" is repeated, though the "name" field is different, to get should not.
The result roughly should be:
Array [
[code => 1, name => a]
[code => 2, name => a]
[code => 3, name => b],
]
July 8th 19 at 16:13
2 answers
July 8th 19 at 16:15
Something like this
$query->groupBy('code');
July 8th 19 at 16:17
Try:
Model::find()->select(['code', 'name'], 'DISTINCT')->all();
Tried it, then it checks that both fields were unique. I tried and so Model::find()->select(['DISTINCT `code`, 'name'])->all(); still both fields checks - vladimir.Wucke commented on July 8th 19 at 16:20

Find more questions by tags YiiSQL