Welcome Guest, Not a member yet? Register   Sign In
Segment-based URL vs Query Strings
#2

In most cases, the segment-based alternative to the URL you've supplied would be something like http://example.com/index.php/customers/i...ill/active or http://example.com/index.php/customers/i...tus/active (you could also filter out the index.php with mod_rewrite, if you wished).

Generally, the first format is easier to support, as you would just setup your Customers controller's index() method to accept two arguments (client_name and status), like this:

PHP Code:
class Customers extends MY_Controller
{
 
   // ... 
 
   
    public 
function index($client_name ''$status '')
 
   {
 
       if ($client_name !== '') {
 
           // do something with $client_name
 
       }
 
       if ($status !== '') {
 
           // do something with $status
 
       }
 
   }


The biggest drawback to this method is that they have to be supplied in a consistent order. If you use the second form (where the name of each section precedes the value, much like the original query string), you can change the order, but you have to spend a little more time mapping the arguments to variables in your controller. The URI class provides a method for getting the URI segments in an associative array from the name/value format called uri_to_assoc().
Reply


Messages In This Thread
RE: Segment-based URL vs Query Strings - by mwhitney - 09-14-2015, 09:31 AM



Theme © iAndrew 2016 - Forum software by © MyBB