开发者

Kohana 3 (ORM or DB) returning single field

开发者 https://www.devze.com 2023-03-14 04:12 出处:网络
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开发者_St

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

精彩评论

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

关注公众号