Search code examples
phpkohana-3kohana-orm

Kohana 3 (ORM or DB) returning single field


What is the best way to retrieve results from one field using DB or ORM?

For example, I need an array of user's friends ids to pass them to other function. I'm currently doing it like this:

$friends_ids = $this->friends->find_all()->as_array('id', 'name');

$friends = array();

foreach ($friends_ids as $k => $v)
{
    array_push($friends, $k);
}

Maybe there's a better way?


Solution

  • $friends = $this->friends->find_all()->as_array(NULL, 'id');