如何在url中屏蔽id(codeigniter)

时间:2016-10-25 11:25:47

标签: php mysql codeigniter

这是我更改网址的路线

$route['default_controller'] = 'Customer';
$route['register'] = 'staff/register'; 
$route['admin'] = 'user/display_admin_dashboard';
$route['customer/display_medicine_prescription'] = 'customer/display_medicine_prescription/(:any)';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
$route[LOGIN_PAGE] = 'examples/login';

客户/ display_medicine_notification / 14

这是我的url如何隐藏id(14)

2 个答案:

答案 0 :(得分:1)

你可以使用slug-name ex:

http://localhost/display_medicine_prescription/(slug-name)

route.php

$route['display_medicine_prescription/(:any)'] = 'customer/display_medicine_prescription';

你的模特:

 public function display_medicine_prescription($slug = FALSE){
        if ($slug === FALSE){
                $query = $this->db->get('medecine');
                return $query->result_array();
        }

        $query = $this->db->get_where('medecine', array('slug' => $slug));
        return $query->row_array();
    }

答案 1 :(得分:0)

试试吧我认为它的工作

  

$ route [" display_medicine_prescription /([0-9] +)/(。*)"] =" customer / display_medicine_prescription&#34 ;;