<?php

/**
 * @filename model_menu.php 
 * @encoding UTF-8 
 * @author 邱伟平 
 * @copyright 连云港龙泽商务有限公司 
 * @datetime 2013-6-25  10:42:48
 * @version 1.0
 * @Description
 */
class Model_menu extends CI_Model {

    public function m_get_menu_by_role($role_id, $type = 'update') {

        if ($type == 'query') {
            $this->db->select('cms_menu.*,cms_menu.parent_id as pId');
            $this->db->join('cms_role_menu', 'cms_menu.id = cms_role_menu.menu_id and cms_role_menu.role_id = ' . $role_id);
        } else {
            $this->db->select('cms_menu.id,cms_menu.parent_id as pId,cms_menu.name,cms_role_menu.checked');
            $this->db->join('cms_role_menu', 'cms_menu.id = cms_role_menu.menu_id and cms_role_menu.role_id = ' . $role_id, 'left');
        }
        $this->db->from('cms_menu');
        $this->db->order_by("cms_menu.sort", "asc");
//        $this->db->where('role_id',$role_id);
        $query = $this->db->get();
        return $query->result();
    }

    /*
     * 开发人员
     */

    public function get_all_menu() {


        $this->db->select('*,parent_id as pId');

        $this->db->from('cms_menu');
        $this->db->order_by("sort", "asc");
//        $this->db->where('role_id',$role_id);
        $query = $this->db->get();
        return $query->result();
    }

}

/* End of file : model_user.php */
