D
D
Doniyor Mamatkulov2018-02-08 13:00:35
Yii
Doniyor Mamatkulov, 2018-02-08 13:00:35

Array from object in Yii2?

Hi all! It's embarrassing to ask, but it doesn't work.
I pull out the countries from the database like this: It is necessary to form an array of this type:Countries::find()->where(['alive'=>1])->all();

"country" => Russia
"code" => +7

"country" => USA
"code" => +1

"country" => Uzbekistan
"code" => +998

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton, 2018-02-08
@doniyorbekm

Countries::find()->where(['alive'=>1])->select(['country', 'code'])->asArray()->all();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question