Return array of IDs for activerecord resultset

Is there a quick and easy way of returning JUST an array of IDs for an ActiveRecord resultset?

So for example, I retrieve my results like so:

$users = User::find()->all();

And I want the result to be returned as follows:

[
    0 => 1,
    1 => 5,
    2 => 7,
    ...
]

Of course I can just foreach over $users and manually assign the IDs to a new array, but I was hoping there would be some built-in method to do this.

Yes:

$ids = User::find()->select('id')->column();
4 Likes

Perfect! Thanks!