php 如何为数组_POST vars yii getPost?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12301639/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to yii getPost for array _POST vars?
提问by Rami Dabain
Assuming i have
假设我有
$_POST["x"]["y"] = 5;
how can i
我怎样才能
Yii::app()->request->getPost('x[y]');
how can i retrieve the post variable by index ? and is there any yii function that checks for sql injection ? does the getPost do that check ?
如何通过索引检索 post 变量?是否有任何 yii 函数可以检查 sql 注入?getPost 会做那个检查吗?
Thank you .
谢谢你 。
回答by Kris
I am not familiar with yii, but looking at the source code for the function https://github.com/yiisoft/yii/blob/1.1.12/framework/web/CHttpRequest.php
我对yii不熟悉,但查看函数的源代码 https://github.com/yiisoft/yii/blob/1.1.12/framework/web/CHttpRequest.php
You would do
你会做
$x = Yii::app()->request->getPost('x');
$y = $x['y'];
The getPost function WILL NOT prevent sql injection. Please read http://www.yiiframework.com/wiki/275/how-to-write-secure-yii-applications/#hh11for more information on securing your yii application
getPost 函数不会阻止 sql 注入。请阅读http://www.yiiframework.com/wiki/275/how-to-write-secure-yii-applications/#hh11了解更多关于保护 yii 应用程序的信息
回答by frops
Yii2
Yii2
$x = Yii::$app->request->post('x');
回答by Davit Huroyan
Yii::app()->request->getParam('delete');
Yii::app()->request->getParam('delete');
you can see this link
你可以看到这个链接
http://www.yiiframework.com/forum/index.php/topic/28547-get-post-parameters-with-the-same-name/
http://www.yiiframework.com/forum/index.php/topic/28547-get-post-parameters-with-the-same-name/
回答by hackil
With model Test it's look like this
使用模型测试,它看起来像这样
$test = new Test();
$test->attributes = Yii::app()->request->getPost('x');
$y = $test->getAttribute('y');
回答by Ignacio Olivieri
> 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));
> }

