List of ids using the model

Is there a direct way to produce an array of ids ([1,2,3,4....]) using the model?

Could you explain what you want with more detail?

Are you talking about something like this: http://docs.phalconphp.com/en/latest/api/Phalcon%5Db%5Result%5Pdo.html

Instead of (SELECT * FROM ....) perhaps (SELECT id FROM ...)



344
edited Apr '15

@ShadMickelberry, thanks but I was not referring to columns. When we use Users::find(['columns'=>'id'])->toArray() it produces:

array(3) {
  [0]=>
  array(1) {
    ["id"]=>
    string(1) "1"
  }
  [1]=>
  array(1) {
    ["id"]=>
    string(1) "2"
  }
  [2]=>
  array(1) {
    ["id"]=>
    string(1) "3"
  }
}

Is there a way that the output is like this

array(3) {
  [0]=>
  string(1) "1"
  [1]=>
  string(1) "2"
  [2]=>
  string(1) "3"
}

Please use code formatting - it's much easier to read. I've updated your last post.

To the best of my knowledge, there is no way using the ORM to get an array like what you want. However, array_walk() could probably be applied pretty easily.