Atitit usrQBM2331 参数格式化规范
String sql = "insert agent(uid,parent_id,pwd,name,tel,wechat,bkkad,sid,uname)values('$uid$','$pid$','$pwd$','$name$','$tel$','$wechat$','$bkkad$','$sid$','$uname$') ";
sql = sql.replace("$uid$", sub_id);
tksvr.setUtype("agent");
sql = sql.replace("$pid$", getuid);
sql = sql.replace("$pwd$", "111111");
HttpServletRequest req = Global.req.get();
try {
req.setCharacterEncoding("utf8");
} catch (UnsupportedEncodingException e1) {
ExUtil.throwExV2(e1);
}
String name=req.getParameter("name");
String name_gbk2utf=EncodeX.gbk2utf(name);
String name_utf2gbk=EncodeX.utf2gbk(name);
Map m = ReqX.toMap(req);
sql = new ParamX().sqlFmtV2(sql, m);
System.out.println(sql);
public String sqlFmtV2(String sql,Map s_GET)
{
List<String> params=findSqlParamV2(sql);
for (String p : params) {
String http_para_name=com.attilax.lang.text.strUtil. str_replace("$","",p);
if(s_GET.get(http_para_name) !=null) {
String string = s_GET.get(http_para_name).toString();
sql=com.attilax.lang.text.strUtil.str_replace(p,string,sql);
}
}
// foreach( $params as $p)
// {
//
// }
return sql;
}
public List<String> findSqlParamV2(String sql)
{
List<String> li=strUtil. preg_match_all(regExpress.ParamNameExpress4sql, sql);
// print_r( $a);
// $GLOBALS["varsx"]["sql params"]=$a;
return li;
}
public static String ParamNameExpress4sql="\$.+?\$";
作者:: 绰号:老哇的爪子 ( 全名::Attilax Akbar Al Rapanui 阿提拉克斯 阿克巴 阿尔 拉帕努伊 )
汉字名:艾提拉(艾龙), EMAIL:1466519819@qq.com
转载请注明来源: http://www.cnblogs.com/attilax/
Atiend