亲爱的所有朋友,我是 Codeigniter 框架的新手,我希望通过选择两个表数据来获得总金额,问题是当我在第二个表中输入数据时,总金额会翻倍。
function total_amount($booking_no = NULL)
{
$data = array('forwarding_cargo_booking_details.*',
'other_charges.client_amount');
$this->db->select($data);
$this->db->where('forwarding_cargo_booking_details.booking_no',$booking_no);
$this->db->join('other_charges','forwarding_cargo_booking_details.booking_no = other_charges.booking_no','left');
$this->db->select('sum((`bk_m3`*`o_freight_client`)*(`selling_rate`)+`pod_client`+`thc_client`+`caf_client`+`baf_client`+`haulage_client`+`war_risk_client`+`warehouse_client`+`thc_dest_client`+`pp_surcharge_client`+`doc_charges_client`+`client_amount`) as salam', FAlSE);
$query = $this->db->get('forwarding_cargo_booking_details');
if($query->num_rows() > 0)
{
return $query->row();
}
}