cakephp 2.4:在url中传递值而不是id?

时间:2014-02-21 13:00:07

标签: cakephp-2.4

我是cakephp的新手,想知道如何更改这样的网址

C:/xyz.com/countries/view/5到C:/xyz.com/countries/ABC

其中5是ABC国家的ID

先谢谢

1 个答案:

答案 0 :(得分:1)

Router::connect('/countries/:country_id', array('controller' => 'countries', 'action' => 'view'), array('pass' => array('country_id')));

在控制器中:

public function view() {
   $countryId =  $this->request->params['country_id'];
}