- Input data 100
- Input data 500
- Input data 400
Menghitung Total Dengan Join Table Codeigniter.
Controler
function hitungtotal($id_entitas)
{
$querys = $this->db->query("
SELECT
Sum(mas_lhpk.hasil_kuantum) AS hasiltotal,
ref_entitas.id_entitas,
ref_entitas.entitas_gudang,
mas_lhpk.rencana_kuantum
FROM
ref_entitas
INNER JOIN mas_lhpk ON ref_entitas.id_entitas = mas_lhpk.id_entitas
where ref_entitas.id_entitas ='".$this->input->post('id_entitas')."'
");
foreach($querys->result() as $row_ver) {
$hasiltotal= $row_ver->hasiltotal;
}
$total = $hasiltotal;
$data2 = array(
'total_kuantum' => $total,
);
$this->db->where('id_entitas',$id_entitas); //cek
$this->db->update('ref_entitas',$data2);
}
No comments:
Post a Comment