GETのクエリ文字列
1 |
/posts/index?page=1&sort=title |
1 2 3 4 |
function index() { $page = $this->request->query('page'); //'1' $sort = $this->request->query('sort'); //'title' } |
名前無しパラメータ
1 |
/posts/index/10/20 |
1 2 3 4 |
function index($param1, $param2) { $param1; //10 $param2; //20 } |
あるいは
1 2 3 4 |
function index() { $this->params['pass'][0]; //10 $this->params['pass'][1]; //20 } |
名前付きパラメータ
1 |
/posts/index/param1:10/param2:20 |
1 2 3 4 |
function index() { $this->params['named']['param1']; //10 $this->params['named']['param2']; //20 } |
名前無し&名前付きパラメータ混在
1 |
/posts/index/param1:10/30/param2:20/40/50 |
1 2 3 4 5 6 7 8 |
function index() { $this->params['named']['param1']; //10 $this->params['named']['param2']; //20 $this->params['pass'][0]; //30 $this->params['pass'][1]; //40 $this->params['pass'][2]; //50 } |
参考サイト
【CakePHP】リクエストの取得方法 – Qiita
http://qiita.com/kazu56/items/7d344ccef56deef66a7a
名前付きでパラメータを受け取る方法 – Writing Some Code
http://d.hatena.ne.jp/ngtn/20080403/1207231914