如何为数组_POST vars yii getPost?
假设我有
$_POST["x"]["y"] = 5;
我该怎么办
Yii::app()->request->getPost('x[y]');
如何通过索引检索 post 变量?是否有任何 yii 函数可以检查 sql 注入?getPost 会做那个检查吗?
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 ?
谢谢.
推荐答案
我对yii不熟悉,但是看了一下函数的源码https://github.com/yiisoft/yii/blob/1.1.12/框架/web/CHttpRequest.php
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
你会这样做
$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 应用程序的更多信息
The getPost function WILL NOT prevent sql injection. Please read http://www.yiiframework.com/wiki/275/how-to-write-secure-yii-applications/#hh11 for more information on securing your yii application
相关文章