开发者

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开发者_StackOverflow社区:

$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?


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜