Search code examples
propel

Any way to get as an array all the values that has a field?


I mean, after after a doSelect(), I get an array of objects, and I'm interested in getting just the values of a field. I'm interested also in storing the values in an array.

I know i could use a foreach and getField() functions, but I'm wondering if there is something like "array getFieldValues()".

Regards

Sf 1.4/Propel 1.6

Javi


Solution

  • If you only want one field of all objects, you can use the select() method of the Query class:

    // When you need only one column, use a column name as the select() argument
    $articles = ArticleQuery::create()
      ->join('Category')
      ->select('Title')
      ->find();
    // returns array('foo', 'bar')