[eluser]jakelehner[/eluser]
Hi all ... I've done some searching on here and haven't found an answer yet. I'm having a hell of a time with the ruri_to_assoc and uri_to_assoc functions, and hope someone can help me out here.
The following scenario happens both in CI 2.0.1 and CI 2.1.0.
I have the following route defined:
Code:
$route['user/(:any)'] = "user/index";
Obviously, the goal here is to not include the method (index in this case) in the URL string. The uri functions mentioned above don't seem to be working as expected. When I access the following URL:
/user/id/3/format/json (which routes to /user/index/id/3/format/json)
I get the following:
Code:
$this->uri->ruri_to_assoc()
generates
Code:
Array
(
[3] => format
[json] =>
)
and
Code:
$this->uri->uri_to_assoc()
generates
Code:
Array
(
[3] => format
[json] =>
)
I'm confused why ruri is returning the same as uri. Here's where it gets interesting ...
both of the following
Code:
$this->uri->ruri_to_assoc(1)
and
$this->uri->uri_to_assoc(1)
return
Code:
Array
(
[user] => index
)
then
Code:
$this->uri->ruri_to_assoc(2)
and
$this->uri->uri_to_assoc(2)
both return
Code:
Array
(
[index] =>
)
BUT ...
Code:
$this->uri->ruri_to_assoc(3)
and
$this->uri->uri_to_assoc(3)
both return
Code:
Array
(
[3] => format
[json] =>
)
wtf? Am I missing something here? It looks like the ruri and uri functions are doing the same thing. I also don't understand why it looks like both functions are counting the PRE-routed url (by counting 'index' as a segment) until I specify the start segment as 3 ... in this case BOTH functions decide to use the post route URL and view 'id' as the method rather than the first segment.
Please telling me I'm missing something easy here.