假设我有
$_POST["x"]["y"] = 5;
我怎么能
Yii::app()->request->getPost('x[y]');
如何通过索引检索post变量?是否有任何yii函数可以检查sql注入?getPost会检查吗?
谢谢。
我不熟悉yii,但正在查看函数的源代码https://github.com/yiisoft/yii/blob/1.1.12/framework/web/CHttpRequest.php
你会做
$x = Yii::app()->request->getPost('x');
$y = $x['y'];
getPost函数不会阻止sql注入。请阅读http://www.yiiframework.com/wiki/275/how-to-write-secure-yii-applications/#hh11有关保护yii应用程序的更多信息
Yii2
$x = Yii::$app->request->post('x');
通过模型测试,它看起来像这个
$test = new Test();
$test->attributes = Yii::app()->request->getPost('x');
$y = $test->getAttribute('y');
Yii::app()->request->getParam('delete');
你可以看到这个链接
http://www.yiiframework.com/forum/index.php/topic/28547-get-post-parameters-with-the-same-name/
> My controller
> public function mi(){
> echo "Hola MI Controlador!";
> // in login scenario
>
> $request = Yii::app()->request->getPost('nombre');
> print_r($request);
>
>
> //$this->render('index',array('nombre',$post));
> }