官方求助,thinkphp如何防注入

2025-04-02 14:27:59
推荐回答(3个)
回答1:

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();
模型的query和execute方法 同样支持预处理机制,例如:
$model->query('select * from user where id=%d and status=%d',$id,$status);
//或者
$model->query('select * from user where id=%d and status=%d',array($id,$status));
execute方法用法同query方法。

回答2:

thinkphp 自带防止注入的函数的

回答3:

对数据进行处理