如何在laravel中选择db后获取数组而不是对象

时间:2015-01-29 12:38:41

标签: select laravel eloquent

我有这个查询

DB::table('my_table')->whereIn('column_id', $tagList)->get(array('product_id'));

但结果我得到了一组stdClass对象

array (size=2)
  0 => 
    object(stdClass)[964]
      public 'product_id' => int 19
  1 => 
    object(stdClass)[961]
      public 'product_id' => int 20

有可能将值作为简单数组获得吗?

array (size=2)
  0 => 19
  1 => 20

1 个答案:

答案 0 :(得分:1)

使用lists

DB::table('my_table')->whereIn('column_id', $tagList)->lists('child_id');
相关问题