codeigniter选择结果数组格式

时间:2015-09-19 16:30:37

标签: php mysql codeigniter select activerecord

我有这段代码:

 $query = $this->db->select( 'cat_id' )
            ->from( 'products_cat' )
            ->where('product_id',$id)
            ->get()
            **->result_array();**
return $query;

以这种格式返回值:

Array ( [0] => Array ( [cat_id] => 2 ) [1] => Array ( [cat_id] => 3 ) [2] => Array ( [cat_id] => 5 ) )

我希望它返回像Array(2,3,5)

这样的简单数组

(没有数组内的数组且没有“cat_id”索引)

我需要改变什么?

1 个答案:

答案 0 :(得分:0)

result_array()返回一个json_decoded数组。使用json_encode($query)