INPUT CLASS destroys global get? |
[eluser]RJ[/eluser]
Quote:Destroys the global GET array. Since CodeIgniter does not utilize GET strings, there is no reason to allow it. Found this is the user guide under http://ellislab.com/codeigniter/user-gui...input.html; further down on the page they provide methods to grab GET data. My question is, can I access a GET string? Thank you! bs
[eluser]xwero[/eluser]
yes CI cleans the GET global but it leaves the SERVER['QUERY_STRING'] alone so all you have to do is Code: $_GET = parse_str($_SERVER['QUERY_STRING']); And then you can even use the CI uri methods afterwards.
[eluser]RJ[/eluser]
So it will take: Code: ?Type=whatever&people=model And place into that into Server query string? Any idea if there are string size limitations to this? I am working with an old scripting system and they are transferring data using GET quite a bit. Will try to get away from soon. Thanks
[eluser]xwero[/eluser]
yes but you can't use the auto uri_protocol because this will try to process the query string in certain circumstances.
[eluser]RJ[/eluser]
I can't auto-load the uri library if i'm trying to access the get string?
[eluser]moodh[/eluser]
[quote author="bullspit" date="1239164450"]I can't auto-load the uri library if i'm trying to access the get string?[/quote] The URI library is loaded by default.
[eluser]Colin Williams[/eluser]
[quote author="bullspit" date="1239160864"]So it will take: Code: ?Type=whatever&people=model And place into that into Server query string?[/quote] Well, that server variable is available whether or not you use CI. xwero just shows you how to repopulate the $_GET superglobal by parsing this environment variable.
[eluser]xwero[/eluser]
Colin thank you for putting my code snippet into context. The SERVER query_string is generated by the sever upon the request that has been received, just like GET but that global puts the query_string in an easier to use array. The parse_str function is like a specialised explode function because it will break the query string like you are used to receive GET and POST input. Oops the use of the parse_str function is wrong, it has to be Code: parse_str($_SERVER['QUERY_STRING'],$_GET);
[eluser]judico[/eluser]
Here is my solution to the occasional need to acquire a querystring parameter value from a GET request. Note: $config['enable_query_strings'] = FALSE; in my config.php Code: /**
[eluser]xwero[/eluser]
judico doing a preg_match for every value you have to get is more expensive than parsing the query string once and putting it in a variable, it doesn't have to be the get global. |
Welcome Guest, Not a member yet? Register Sign In |