• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
mixing URI query and URI Segment

#1
[eluser]tominku[/eluser]
CI's uri convention is class/function/parameter1/parameter2

but is it possible to use like this?

http://my_site.com/index.php/blog/write/...&memo=blah

but it wasn't work.. i saw "invalid URI" message

in fact, it is inconvenient to just depend on the sequence of parameter like this

URI: blog/write/kang/hi/blah
USAGE:
Code:
class Blog extends Controller{
        function write($name, $subject, $memo){
             ...some db related working.....
        }
    }

#2
[eluser]xwero[/eluser]
you can do http://my_site.com/index.php/blog/write/.../memo/blah. But i hope you understand the limits of the query string approach. Those values you attach to the url should be posted.

Said that you can extract the url as follows
Code:
$params = $this->uri->uri_to_assoc(3);
// which gives you
array('name'=>'kang','subject'=>'hi','memo'=>'blah')

#3
[eluser]tominku[/eluser]
so... is it possible to use like this?
http://my_site.com/index.php/blog/write/...&memo=blah

it brings out the message "The URI you submitted has disallowed characters."

#4
[eluser]xwero[/eluser]
I think it works if you do http://my_site.com/index.php/blog/write/...&memo=blah and set the enable_query_string to true in the config file. But then you have to get the values using $_GET['name'] or $this->input->get('name')

#5
[eluser]tominku[/eluser]
thank you very much!
i set enable_query_string to true, then it works!

but there is some bug..

http://localhost:8888/codeigniter/index.php/blog/getList/?name=kang&subject=hi
it works. but...

http://localhost:8888/codeigniter/index.php/blog/getList/?name=kang
(bring out the message "The page you requested was not found.")
i think the number of parameters should be at least two..

#6
[eluser]xwero[/eluser]
Yes you are right that is because of following code in the _fetch_uri_string in the uri library
Code:
if (strtoupper($this->config->item('uri_protocol')) == 'AUTO')
        {
            // If the URL has a question mark then it's simplest to just
            // build the URI string from the zero index of the $_GET array.
            // This avoids having to deal with $_SERVER variables, which
            // can be unreliable in some environments
            if (is_array($_GET) AND count($_GET) == 1)
            {
                $this->uri_string = key($_GET);            
                return;
            }

#7
[eluser]Jonathon Hill[/eluser]
So is this a bug?

Code:
// If the URL has a question mark then it's simplest to just
// build the URI string from the zero index of the $_GET array.
// This avoids having to deal with $_SERVER variables, which
// can be unreliable in some environments
if (is_array($_GET) AND count($_GET) == 1 AND trim(key($_GET), '/') != '')
{
    $this->uri_string = key($_GET);            
    return;
}

Since when does $_GET contain the URI string?? This doesn't appear to work at all - is it a bug? What am I missing?


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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