thinkphp如何防SQL注入

thinkphp如何防SQL注入

thinkphp防SQL注入的方法:

1.系统底层对于数据安全方面本身进行了相应的防范机制,例如:

$User = M(\"User\"); // 实例化User对象

$User->find($_GET[\"id\"]);

2.查询条件进行预处理,where方法使用字符串条件时,进行安全过滤,并支持两种方式传入预处理参数,例如:

$Model->where(\"id=%d and username=\'%s\' and xx=\'%f\'\",array($id,$username,$xx))->select();

// 或者

$Model->where(\"id=%d and username=\'%s\' and xx=\'%f\'\",$id,$username,$xx)->select();

赞(0)
未经允许不得转载:主机测评网 » thinkphp如何防SQL注入
分享到: 更多 (0)