如何为数组_POST vars yii getPost? [英] how to yii getPost for array _POST vars?

查看:16
本文介绍了如何为数组_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

这篇关于如何为数组_POST vars yii getPost?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆