开发者

codeigniter way to write mysql join query

i want to write this query on codeigniter way. the query is:

S开发者_Python百科ELECT 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


You could do something like this. You can find more help in the CI docs

$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');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜