将MySQL查询转换为Codeigniter语法

时间:2011-06-21 08:52:43

标签: php mysql codeigniter

我在将MYSQL查询转换为CI语法时遇到了一些问题。

这是我的MySQL语法:

select a.pbj_name as 'NAMA PERUSAHAAN', count(a.id_pbj) as 'JUMLAH PAKET', group_concat(c.paket_kode) as 'PILIHAN PAKET'
from jed_pbj a
left join jed_paket_pbj b
       on a.id_pbj=b.id_pbj
left join jed_paket c
       on b.id_paket=c.id_paket
group by a.id_pbj

1 个答案:

答案 0 :(得分:1)

在Codeigniter中查看此Active Record课程,

$this->db->select("a.pbj_name as 'NAMA PERUSAHAAN', count(a.id_pbj) as 'JUMLAH PAKET', group_concat(c.paket_kode) as 'PILIHAN PAKET'");
$this->db->from('jed_pbj a');
$this->db->join('jed_paket_pbj b', 'a.id_pbj=b.id_pbj', 'left');
$this->db->join('jed_paket c', 'b.id_paket=c.id_paket', 'left');
$this->db->group_by("a.id_pbj"); 
$this->db->get();