本文介绍了真正的转义字符串和 PDO的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在从 mysql
库迁移后使用 PDO.我用什么来代替旧的 real_escape_string
函数?
I'm using PDO after migrating away from the mysql
library. What do I use in place of the old real_escape_string
function?
我需要转义单引号,以便它们进入我的数据库,我认为可能有更好的方法来处理这个问题,而无需在所有字符串中添加(ing)斜杠.我应该使用什么?
I need to escape single quotes so they will go into my database and I think there may be a better way to handle this without add(ing) slashes to all my strings. What should I be using?
推荐答案
你应该使用 PDO准备
来自链接:
为将使用不同参数值多次发出的语句调用 PDO::prepare() 和 PDOStatement::execute() 通过允许驱动程序协商客户端和/或服务器端缓存来优化应用程序的性能查询计划和元信息,并且通过消除手动引用参数的需要来帮助防止 SQL 注入攻击.
这篇关于真正的转义字符串和 PDO的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!