K
K
kastselito2022-02-01 20:58:20
Yii
kastselito, 2022-02-01 20:58:20

How to make several fields on yii2 distinct without losing the rest?

Greetings
I'm making a query like this
$model = Files::find()->select(['filename','ext','size'])->distinct()->all();
There is uniqueness in three fields.
Everything is great.
But there are more fields in the Files table. How can I get them?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Michael, 2022-02-01
@Akela_wolf

Yii2 Query builder does not know how to distinct on
There is such a hack : either write the entire SQL query by hand. Model::find()->select('distinct on (a) *')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question