как получить доступ к параметру, переданному в запросе - PullRequest
0 голосов
/ 26 октября 2010

как получить доступ к этому параметру в контроллере ..?

$router->map('Company', 'Company', array( 
 'controller' => 'companies', 
 'action' => 'add', 
 'paramkey' => 'paramvalue', 
 'anotherparam' => 'anothervalue')); 

Пожалуйста, помогите мне

Ответы [ 2 ]

0 голосов
/ 26 октября 2010

получить один параметр:

$this->getRequest()->getParam('paramkey'[, 'default value']);

получить все параметры:

$this->getRequest()->getAllParams();

или

$this->_getParam('paramkey'[, 'default value']);
$this->_getAllParams();

Я использую Zend Framework, поэтому метод описан в Zend_Action_Contoller:

/**
 * Gets a parameter from the {@link $_request Request object}.  If the
 * parameter does not exist, NULL will be returned.
 *
 * If the parameter does not exist and $default is set, then
 * $default will be returned instead of NULL.
 *
 * @param string $paramName
 * @param mixed $default
 * @return mixed
 */
protected function _getParam($paramName, $default = null)

если вы используете CacePHP, вы можете попробовать

$this->params['paramkey'];

, но я не уверен, что он будет работать

0 голосов
/ 26 октября 2010

Попробуйте

$this->getRequest()->getParam('paramkey');
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...