O
O
Oversec2016-09-16 23:35:12
Yii
Oversec, 2016-09-16 23:35:12

How to get a key-value array from a database?

For the filter in the GridView, I need to get the User id and his name. How can I get it from the table and cast it to an array like

array [
id => 'name',
id => 'name'
// и тд
];

I tried to do the usual ->asArray()->all() but something did not work out...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton, 2016-09-17
@Oversec

ArrayHelper map will help you.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question