![]() |
Codeigniter Query Strings - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Codeigniter Query Strings (/showthread.php?tid=11601) |
Codeigniter Query Strings - El Forum - 09-15-2008 [eluser]Craig N[/eluser] Hi all, I'm using CI with query strings turned on due to the hosting environment I'm creating this web app for. My question is pretty simple although I can't seem to find it - how do I pass arguments to the methods in my controllers? I'm used to using uri segments like index.php/controller/method/argument 1/argument 2/etc. I did a search and didn't find this in the user guide and trying to pass the arguments as normal get variables didn't seem to work either. Thanks in advance ![]() Codeigniter Query Strings - El Forum - 09-15-2008 [eluser]Colin Williams[/eluser] Add slashed params http://www.example.com/controller/function/id/param1/param2/etc I believe you'll only get /id/ passed to your controller, but the rest should be captured with $this->uri->segment(n) or other Uri class functions EDIT: Quote:Your function will be passed URI segments 3 and 4 ("sandals" and "123"): Doesn't get much clearer than that. Codeigniter Query Strings - El Forum - 09-15-2008 [eluser]metaltapimenye[/eluser] what arguments are u expected come from?.. as exemple, it could come from anything. Code: function student_detail($id){ Codeigniter Query Strings - El Forum - 09-15-2008 [eluser]Craig N[/eluser] I'm using query strings Colin, not slashed params i.e. index.php?c=controller&m=method. Are you suggesting passing urls like index.php?c=controller&m=method/param1/param2/ ? That doesn't seem right. for example, let's say I've got a main controller and a search method Normally I would go index.php/main/search/keywords/ to get my search results. However using query strings I have to go to the URL index.php?m=main&c=search. How do I pass the keywords without using a $_POST variable? If I try &keywords=some+keywords, I can't retrieve it as a $_GET variable. Codeigniter Query Strings - El Forum - 09-16-2008 [eluser]metaltapimenye[/eluser] hooo.... $this->input->get(), as writen at <a href="http://ellislab.com/codeigniter/user-guide/libraries/input.html">User Guide</a> $this->input->get('something') as replacement for $_GET. ..but i havent tested yet dough. >_< i wonder how does 'index.php?c=class&f=function&p1=param1' could be able in CI in the first place? on my perspective it would be nicer if 'index.php/c/class/f/function/p1/param1' to read.. <soon i'll put some .htacces to remove 'index.php' part> Codeigniter Query Strings - El Forum - 09-16-2008 [eluser]metaltapimenye[/eluser] i found it.. ..and tried it.. for sure 'query string' development in CI havent end yet. Code: function something(){#i still cannot get the way to put argument in it Codeigniter Query Strings - El Forum - 09-16-2008 [eluser]Craig N[/eluser] Awesome, thanks! Yeah, I like the /controller/method/arg1/arg2/ version too, but unfortunately I can't use it on this project due to the company hosting their domain with their cms provider (which has some messed up htaccess rules) Codeigniter Query Strings - El Forum - 09-16-2008 [eluser]Bramme[/eluser] example.com/controller/method/var1/var2 translates to Code: class Controller { edit: basically what Michael said in his first reply. Codeigniter Query Strings - El Forum - 09-16-2008 [eluser]Phil Sturgeon[/eluser] [quote author="Bramme" date="1221573497"]example.com/controller/method/var1/var2 translates to Code: class Controller { edit: basically what Michael said in his first reply.[/quote] He's looking for normal query strings, not CI url segments. Listen to the mans request ;-) I'm very glad they added $this->input->get(); it has made everyone's lives a little easier. |