假设我有一个名为user的控制器和一个myurl如下所示的方法。 mylink方法使用分页支持从数据库生成url列表。
class User extends CI_Controller{
public function __construct()
{
parent::__construct();
}
public function mylink($id){
/*
Here I want to delete the url(pseudo code :) )
//Check
IF GET request THEN
COLLECT the url ID and DELETE the url
DISPLAY success msg
ELSE
DISPLAY success msg
ENDIF
/*
This function will generate url and pagination
*/
//pagination settings
$config['base_url'].........
......
....
//End of pagination settings (I dont want to write whole text)
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
//call the model function to get the Url data
$data['urllist'] = $this->user_model->GetUrl($config["per_page"], $id);
/*
urllist contain url details and passed to view. where It will create delete url from respective url id like
http://example.com/mylink/del/1
http://example.com/mylink/del/1
http://example.com/mylink/del/1
http://example.com/mylink/del/1
*/
$this->load->view("layout/header");
$this->load->view("mylink",$data);
$this->load->view("layout/footer");
}
}
在我设置的路线中
/*
this is for pagination like
http://example.com/mylink/1
http://example.com/mylink/1
http://example.com/mylink/1
*/
$route['mylink'] = 'user/mylink';
$route['mylink/(:num)'] = 'user/mylink/$1';
$route['mylink/del/(:num)'] = 'user/mylink/$1'; //***** Dont understand here how to set*****
但我不明白如何设置删除网址路由并使其正常运行。请帮我解决一下这个。感谢