【发布时间】:2013-02-15 22:43:17
【问题描述】:
对于 cakePHP 路由,我明白如果你这样做了
Router::connect(
'/:controller/:id',
array('action' => 'view'),
array('id' => '[0-9]+')
);
这将映射到http://www.mywebsite.com/controller/view/id 的任何网址,
但是映射http://www.mywebsite.com/controller/id/action 的网址怎么样?
例如:http://www.mywebsite.com/classes/3/create/2
在我的类控制器中的创建函数中,
它将接收参数$id,在本例中为3,$count,在本例中为2,
public function create( $id, $count ) {
....
// i can here create a total number of $count students
// and assign them class_id $id
// so student1.class_id = 3
// and student2.class_id = 3
}
我试过了,
Router::connect(
'/:controller/:id/:action',
array('id' => '[0-9]+'),
array('count' => '[0-9]{,2}')
);
这对我不起作用。
【问题讨论】:
标签: cakephp routing controller