I'm trying to a straightforward resultset as an array, from CodeIgniter, and I cannot figure out what I'm doing wrong. Maybe something has changed with CodeIgniter 3.0.4 which I am now using.
I'm trying to get a simple array that I can pass directly to a view dropdown box. Instead I am getting a multi dimensional array which I have to decode.
I've tried various methods without success:
- result()
- result_array()
- row_array()
What on earth am I missing?
$strSQL = "SELECT DISTINCT PurchasingGroup FROM snapshot";
$query=$this->db->query($strSQL);
$data=$query->result_array();
Array ( [0] => Array ( [PurchasingGroup] => AAA ) [1] => Array ( [PurchasingGroup] => BBB ) [2] => Array ( [PurchasingGroup] => CCC ) [3] => Array ( [PurchasingGroup] => DDD) [4] => Array ( [PurchasingGroup] => EEE ) [5] => Array ( [PurchasingGroup] => P&P Deve ) [6] => Array ( [PurchasingGroup] => FFF ) [7] => Array ( [PurchasingGroup] => GGG ) [8] => Array ( [PurchasingGroup] => HHH ) [9] => Array ( [PurchasingGroup] => III ) [10] => Array ( [PurchasingGroup] => JJJ ) [11] => Array ( [PurchasingGroup] => KKK) [12] => Array ( [PurchasingGroup] => LLL ) )
return array_column($this->db->distinct()->select('PurchasingGroup')->get('snapshot'), 'PurchasingGroup');