[eluser]Spir[/eluser]
Hi.
I have made a method within a controller. I use that method to output some JSON.
If I want one element i set the ID in parameter.
If I want the whole list I don't give the ID but I can set a limit and the number of the first element in the list (for pagination).
so I have this URLs :
website.com/controller/json/<
id> -> in order to get
one element with id in param
website.com/controller/json/-> in order to get the whole list
website.com/controller/json/<
0>/<
50> -> in order to get the
first 50 elements in the list.
website.com/controller/json/<
40>/<
10> -> in order to get
the 40th to the 49th elements in the list.
My method is :
Code:
function Json($id='', $start='', $step=''){
...
}
I set y route :
$route['controller/json/(:num)/(:num)'] = "controller/json/
??/$1/$2";
$route['controller/json/(:num)'] = "controller/json/$1";
$route['controller/json/'] = "controller/json/"; // optional?
What should I put where I have my
??
Maybe I can't set a param to null directly in route so maybe I should set my function like this :
Code:
function Json($param_one, $param_two){
// And here check if there is only 1 param set then get an element for that ID
// or get the list using the 2 param
...
}
But it sucks...