我想尝试在控制器上添加foreach,因为在我向你展示视图之前
这是我的控制器
$data['report_data'] = $this->hasil_m->get_data($nomor);
//create foreach here, from data $data['report_data']
$data=array('title' =>'KOPKAR - Pelanggan',
'isi' =>'admin/hasil'
);
$this->load->view('dashboard/wrapper',$data);
这是我的模特
$this->db->select('*');
$this->db->from('tb_produk as pro');
$this->db->join('tb_reseller as res', 'pro.reseller_produk = res.nomor_reseller');
$this->db->join('tb_pelanggan as pel', 'pro.id_barcode = pel.id_barcode');
$this->db->select_sum('jumlah');
$this->db->group_by('res.nomor_reseller');
$ambil = $this->db->get('');
if ($ambil->num_rows() > 0) {
foreach ($ambil->result() as $data) {
$hasil[] = $data;
}
return $hasil;
}
这是我的观点
答案 0 :(得分:0)
而不是:
foreach ($ambil->result() as $data) {
$hasil[] = $data;
}
return $hasil;
只是
return $ambil->result_array();