我想在codeigniter方式上写这个查询。 查询是:
SELECT M. * , P.name as page_name
FROM omc_menu AS M
LEFT JOIN omc_page AS P ON M.page_id = P.id
WHERE M.parentid ='0'
ORDER BY `M`.`parentid`,`M`.`order` ASC
答案 0 :(得分:1)
你可以这样做。您可以在CI文档中找到更多帮助
$this->db->select('M.*, p.name as page_name', FALSE);
$this->db->from('omc_menu as M');
$this->db->join('omc_page as P', 'M.page_id = P.id', 'left');
$this->db->where('M.parentid', '0', FALSE);
$this->db->order_by('M.parentid,M.order','ASC');