codeigniter展平查询结果数组

Cyb*_*kie 3 php arrays codeigniter

我在Codeigniter中使用查询来返回属于用户的所有行的ID.

$this->db->select('id');
$this->db->where('user_id', 99);
$query = $this->db->get('my_table');
return $query->result_array();
Run Code Online (Sandbox Code Playgroud)

这回来了

Array ( [0] => Array ( [id] => 8 ) [1] => Array ( [id] => 7 ) [2] => Array ( [id] => 6 ) )
Run Code Online (Sandbox Code Playgroud)

有可能返回像平面阵列一样

Array ( [0] => 8 [1] => 6 [2] => 7 )
Run Code Online (Sandbox Code Playgroud)

Min*_*ihi 8

$b = array();
foreach($query->result_array() as $a) {
   $b[] = $a['id'];
}
return $b;
Run Code Online (Sandbox Code Playgroud)

如果您每次选择一列时都懒得添加几行,则需要调整Codeigniter.就像添加一些选项或选择单列时返回展平数组一样.我会sugest添加一个选项