传递参数,这是我的控制器(未完明显,但“做一些神奇的”我首先要使其运行):CakePHP的:缺少参数错误,通过URL
public function add($customer_id, $question_set_id, $order_value) {
$customer_id = $this->params['url']['customer_id'];
$question_set_id = $this->params['url']['question_set_id'];
$order_value = $this->params['url']['order_value'];
$possible_answer_model = ClassRegistry::init('PossibleAnswer');
$question_model = ClassRegistry::init('Question');
$order_model = ClassRegistry::init('Order');
$order = $order_model -> find('first', array(
'Order.question_set_id' => $question_set_id,
'Order.value' => $order_value));
$question = $question_model -> find('first', array(
'Question.id' => $order['Order']['question_id']));
$this -> set('question', $question);
if ($question['Question']['kind'] != "o") {
$this -> set('possible_answers', $possible_answer_model -> find('all', array(
'PossibleAnswer.question_id' => $question['Question']['id'])));
}
.
.
.
我得到的是:
警告(2):缺少参数1 AnswersController ::添加()[APP \控制器\ AnswersController.php,线10]
警告(2):缺少参数2 AnswersController ::添加() [APP \ Controller \ AnswersController.php,第10行]
警告(2):缺少参数3 AnswersController ::添加()[APP \控制器\ AnswersController.php,线10]
我的链接是:
/答案/添加/?CUSTOMER_ID = 1 & question_set_id = 1 & ORDER_VALUE = 1
哦,我发现“我的方式”在食谱的某个地方,所以我可能搞砸了 - 链接正在工作,但我得到“未定义索引”错误$ customer_id = $ this-> params ['url' ] ['customer_id']和另外两个$ this-> params ... – smsware 2012-07-11 06:25:43
这是或者。如果你没有在URL中传递它们作为'?customer_id = 1',它们在'$ this-> params'中不可用。 – deceze 2012-07-11 06:29:15
哦,现在工作 - 谢谢! – smsware 2012-07-11 06:30:58