Using a query string inside of a clean url.

#11
[eluser]Phil Sturgeon[/eluser]
[quote author="Colin Williams" date="1234202838"]do http://ci.localhost/books/search/phrase/my+search instead[/quote]

There is nothing wrong with using both URI segments and a normal query string.

I have seen so many posts from you saying new users here worry about always doing things the CI way and should not be afraid to mix with native code and old fashioned methods. This is a perfect example!

URI segments are for clean URL structure yes, but they should mainly be used for SEO and logical controller selecting. If you want to pass an unknown number of variables from a form to a controller that does not know or care what order they in or how many there are, I cannot see a better way.

Sure you could send the GET to a controller which formats the URL and sends the result controller an associative URL, but what is the point?

Anyhow, url_decode() should take the crazy values out of the GET parameters.

#12
[eluser]Colin Williams[/eluser]
Is there anything wrong with using segments over query strings? I don't get the contention.

#13
[eluser]Colin Williams[/eluser]
Quote:That means I’d have to know which of the URI parameters to grab.

Not necessarily. You could iterate over $this->uri->uri_to_assoc() and then it's dynamic.

Code:
$params = $this->uri->uri_to_assoc();
foreach ($params as $key => $value {
  $this->db->where($key, $value);
}

Just like you would iterate over the $_GET superglobal. There's no difference.

#14
[eluser]Unknown[/eluser]
Woohoo! Easier than I thought indeed. The config is a little strange though. How can this be not default?


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.