我使用PDO声明如下SQL注入:哪些语句可以防止较好SQL注入
select * from `admine_user` where `user_id` = ? and passw = ?
$resultfm1 = DB::instance()->prepare($query)->execute
(array($escapedid,$hashedpass))->fetchAll();
我想用
select * from `admine_user` where `user_id` = :user and passw = :pwd
$resultfm1 = DB::instance()->prepare($query)->execute
(array(":user"=>$escapedid,":pwd"=>$hashedpass))->fetchAll();
出上述声明这是更好地使用它可以有效防止SQL注入,因为现在我不能使用mysql_real_escape_string
既防止.. – sectus
感谢@sectus ..有人downvoted,我可以知道原因,并感谢谁upvoted的人。我认为,我们在这里学习 – Gags
你应该确保你的准备不被模拟('$ con> setAttribute(PDO :: ATTR_EMULATE_PREPARES,false);') - [Read More。](http://stackoverflow.com/questions/ 8776344 /如何对 - 视图 - 查询错误在-PDO-PHP/8776392#8776392)。但是,两个查询都是一样的。 – Darren