在Codeigniter中为每个控制器启用查询字符串

Is there a way to enable query string in just one controller or for one function. For example, I want to use query string in search function, and segments in every other.

Is there a way to do this?

Can I do something like this:

$this->config->set_item('uri_protocol', 'PATH_INFO');
$this->config->set_item('enable_query_strings', TRUE);

A simple way to achieve this is by parsing the server query string like so.

$get_data = array();

parse_str($_SERVER['QUERY_STRING'], $get_data);

This will leave you with a very insecure array full of data, so you should use CI's security class to make it more secure; so like;

$get_data = $this->security->xss_clean($get_data);

This will not mean that routing works via GET, only allow you to get the GET vars safely.