C
C
CTS42017-01-26 20:29:12
Yii
CTS4, 2017-01-26 20:29:12

Get array with all user ids from database after find() yii2?

I get all users without a ban from the database, tell me how to get an array with only the id of all users.
$ids = Users::find(["baned" => $no ])
->all();
tried $ids_array = $ids['id']; does not work.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Abdula Magomedov, 2017-01-26
@CTS4

$ids = Users::find(["baned" => $no ])->select("id")->asArray()->column()

M
melnikov_m, 2017-01-26
@melnikov_m

$ids = Users::find(["baned" => $no ])
->asArray()->all();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question