Query strings |
[eluser]jt`[/eluser]
Let's say I'm in the library someLibrary. How would I access a particular query string in the URL, let's say it's &someParam=someString. So, if I'm in someLibrary, looking at function SomeFunction(){}, how could I get &someParam;? Is there a direct call to get query strings that I'm not seeing? Or does it need to be passed from the controller or function that is being used? If so, how would I pass it? Much thanks in advance to anyone who could chime in and help me out on this one. -JT
[eluser]Pascal Kriete[/eluser]
$_GET['someParam'] or even better $this->input->get('someParam') (if you're in a library you'll need a reference to the CI super object). EDIT: To clarify the reference thing: Code: $CI =& get_instance();
[eluser]jt`[/eluser]
inparo: excellent, thank you. P.S. If you liked Hancock, you'll love Wanted. The very last line in the movie is the best part.
[eluser]Seppo[/eluser]
@inparo I believe your example will look better if you use $CI instead of $this =)
[eluser]jt`[/eluser]
I'm not sure if anyone can chime in on this, but while we're on the topic of query strings... I love the Form Validation approach of validating $POST variables (http://ellislab.com/codeigniter/user-gui...ation.html). Is there an easy way to use the same validation class on query strings? I tried to hack at it a little, with no luck. Also, the documentation only explains the use case of an HTML form.
[eluser]Pascal Kriete[/eluser]
Whoops, thanks Seppo - fixed. @jt - I'll make a point of watching it . You could make a copy of the library, call it something else, and replace all $_POST references with $_GET . If you only need to check one rule, remember that individual rules are simply public methods. You can call any of them. Example - alpha-numeric check: Code: $this->load->library('validation'); |
Welcome Guest, Not a member yet? Register Sign In |