微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

php – 真正的转义字符串和PDO

参见英文答案 > How can I prevent SQL injection in PHP?                                    28个
迁移远离MysqL库后我正在使用PDO.我用什么来代替旧的real_escape_string函数

我需要转义单引号,以便它们进入我的数据库,我认为可能有更好的方法来处理这个,而不添加(斜)所有字符串的斜杠.我该怎么用?

解决方法:

你应该使用PDO Prepare

链接

Calling PDO::prepare() and PDOStatement::execute() for statements that will be issued multiple times with different parameter values optimizes the performance of your application by allowing the driver to negotiate client and/or server side caching of the query plan and Meta information, and helps to prevent sql injection attacks by eliminating the need to manually quote the parameters.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐