how to yii getPost for array _POST vars?(如何为数组_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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何为数组_POST vars yii getPost?


基础教程推荐
- 在 CakePHP 2.0 中使用 Html Helper 时未定义的变量 2021-01-01
- HTTP 与 FTP 上传 2021-01-01
- 如何在 Symfony 和 Doctrine 中实现多对多和一对多? 2022-01-01
- PHP 守护进程/worker 环境 2022-01-01
- 如何在 XAMPP 上启用 mysqli? 2021-01-01
- Doctrine 2 - 在多对多关系中记录更改 2022-01-01
- 找不到类“AppHttpControllersDB",我也无法使用新模型 2022-01-01
- phpmyadmin 错误“#1062 - 密钥 1 的重复条目‘1’" 2022-01-01
- 使用 PDO 转义列名 2021-01-01
- 在 yii2 中迁移时出现异常“找不到驱动程序" 2022-01-01