I am new to code Igniter framework, and I want to send querystring data, with $this->index(), function, how can i do this, I have done editing in config.php file, to accept query strings.
2 Answers
Your question is not clear at all. As an indication on how to work, though:
As it seems you already did, you must set to TRUE the "enable_query_string" config index:
$config['allow_get_array'] = TRUE;
$config['enable_query_strings'] = TRUE;
$config['controller_trigger'] = 'c';
$config['function_trigger'] = 'm';
As you see, you also have an index for the $_GET array where controllers and models will be placed. In order to build a url (which you must do manually, since the helpers work with uri segments) you can do something like:
index.php?c=mycontroller&m=mymethod&var1=var1
which maps to Mycontroller() controller class and Mymethod() class method, and works the same as for uri segments. In your methods, to retrieve the query string variables after the method, you can:
- use the
$this->input->get('var1')input method to retrieve the query string part; - use the "regular" $_GET array (which you have enabled by passing TRUE to the config index, as above),
$_GET['var1'] just pass the argument to the method (as in uri segments):
function mymethod($var1) { echo $var1; {
"c" and "m" are default triggers, which you can obviously change to whatever you like (just set them in the 2 config indexes, of course).
Comments
In Code Igniter you may use $this->input->get() inside your controller functions. You can also use PHP's $_GET array. More information in the documentation at http://codeigniter.com/user_guide/libraries/input.html