这样写存在sql注入风险吗
public function getList($author){
$sql="select ID,post_author,post_title,post_name from tt_posts where post_author='".$author."' or post_title LIKE '%".$author."%' order by ID desc limit 8";
$result=$this->db->query($sql);
return $result->result();
}
没有对$author进行处理。这样写存在sql注入风险吗?如果有风险,怎么防范。
$author变量里面如果有一个';你的sql就被截断了 $sql="select ID,post_author,post_title,post_name from tt_posts where post_author=".$this->db->escape($author)." or post_title LIKE '%".$this->db->escape_like_str($author)."%' order by ID desc limit 8";
$this->db->query($sql); qi_ruo 发表于 2013-7-6 12:17 static/image/common/back.gif
谢谢,很好很强大!
手册里有这部分,可以详细参考 請愛用CRUD!!
页:
[1]