如何更改CI
$sql1= "SELECT kwsn,SUM(jumlah) as jumlah, count(DISTINCT y.noid) as noid from
(select DISTINCT (a.noid_new) AS noid, a.kwsn FROM tagihandonatur a where Bulan=".$bulan." and kodej='".$_POST['id_usr']."') z
left join (SELECT noid,SUM(jumlah) as jumlah FROM report_tagih WHERE ((tanggal>= '".$tgl."' and tanggal<= '".$tgl2."') OR tanggal like '".$tgl."%' ) and kodej='".$_POST['id_usr']."'
group by noid) y on y.noid= z.noid
group by z.kwsn order by z.kwsn";
$rs= $dtaccess->Execute($sql1);
$dataTotal=$dtaccess->FetchAll($rs);
答案 0 :(得分:0)
在CI中:
$sql1="SELECT kwsn,SUM(jumlah) as jumlah ,count(DISTINCT y.noid) as noid from (select DISTINCT (a.noid_new) AS noid, a.kwsn FROM tagihandonatur a where Bulan=".$bulan." and kodej='".$_POST['id_usr']."') z left join (SELECT noid,SUM(jumlah) as jumlah FROM report_tagih WHERE ((tanggal>= '".$tgl."' and tanggal<= '".$tgl2."') OR tanggal like '".$tgl."%' ) and kodej='".$_POST['id_usr']."' group by noid) y on y.noid= z.noid group by z.kwsn order by z.kwsn";
$data = $this->db->query($sql1);
if($data->num_rows() > 0) {
$d = $q->result_array();
return $d;
} else {
return array();
}