CakePHP在Controller :: redirect中传递参数

tra*_*nte 4 php redirect cakephp cakephp-2.0

在控制器动作中进行重定向我使用:

$this->redirect(array('controller' => 'tools', 'action' => 'index'));
Run Code Online (Sandbox Code Playgroud)

或这个

$this->redirect('/tools/index');
Run Code Online (Sandbox Code Playgroud)

当我使用重定向传递数据时,我使用:

$this->redirect('tools/index/?myArgument=12');
Run Code Online (Sandbox Code Playgroud)

但我找不到如何通过"this-redirect-array"表示法传递"myargument".
我不想使用它,因为一些路由问题:

$this->redirect(array('controller' => 'tools', 'action' => 'index', "myArgument"));
Run Code Online (Sandbox Code Playgroud)

我需要这样的东西:

$this->redirect(array('controller' => 'tools', 'action' => 'index', "?myArgument=12"));
Run Code Online (Sandbox Code Playgroud)

472*_*084 16

Cake确实使用问号支持查询参数,如下所示:

$this->redirect(array(
    'controller' => 'tools', 'action' => 'index', '?' => array(
        'myArgument' => 12
    )
));
Run Code Online (Sandbox Code Playgroud)

http://book.cakephp.org/2.0/en/development/routing.html#reverse-routing

但这样做会更好,就像des说的那样:

$this->redirect(array(
    'controller' => 'tools', 'action' => 'index', 'myArgument' => 12
));
Run Code Online (Sandbox Code Playgroud)