我正在使用CakePHP的2.6.1版本。我创建了一个名为AndroidController.php的控制器,它看起来像
<?php
class AndroidController extends AppController {
public function survey_question()
{
Configure::write('debug', '2');
$survey_id = $_REQUEST['survey_id'];
$this->layout = "";
//$condition = "Question.survey_id = '".$survey_id."'";
$info = $this->Question->find('all', array(
'conditions' => array(
"Question.survey_id" => $survey_id /*dont use array() */
)
));
echo json_encode($info);
exit;
}
}
?>
因此,它会出现类似
的错误错误:未在控制器中定义操作admin_survey_question AndroidController
错误:在文件中创建AndroidController :: admin_survey_question():app / Controller / AndroidController.php。
注意:我的网站网址是 http://navyon.com/dev/mt/admin/android/survey_question?survey_id=2
那我怎么解决这个问题?
答案 0 :(得分:2)
您已为该操作启用admin_
路由,因此您的操作应在<?php
class AndroidController extends AppController {
public function admin_survey_question()
{
Configure::write('debug', '2');
$survey_id = $_REQUEST['survey_id'];
$this->layout = "";
//$condition = "Question.survey_id = '".$survey_id."'";
$info = $this->Question->find('all', array(
'conditions' => array(
"Question.survey_id" => $survey_id /*dont use array() */
)
));
echo json_encode($info);
exit;
}
}
?>
之前
然后您的行动如下所示:
admin
如果您不希望为该操作启用url
路由,请从http://navyon.com/dev/mt/android/survey_question?survey_id=2
删除管理员,然后按以下方式访问:
reduce