[英]PHP: Using quote() on strings in MDB2 with MYSQL
I'm using Pear's MDB2 and really enjoying it, but there is something that is starting to annoy me. 我正在使用Pear的MDB2并非常喜欢它,但是有些事情开始惹恼我。 I build the SQL string in the following way, using the quote method of the mdb2 package: 我使用mdb2包的quote方法以以下方式构建SQL字符串:
$sql = sprintf("INSERT INTO profiles(email, fullName) VALUES(%s,%s)",
$mdb2->quote($email), $mdb2->quote($fullName));
(as explained in the example on this page: http://pear.php.net/manual/en/package.database.mdb2.intro-quote.php ) (如本页示例中所述: http : //pear.php.net/manual/en/package.database.mdb2.intro-quote.php )
and everything looks nice in the database. 数据库中的一切看起来都很不错。 But when I extract data from the database, still using MDB2 I can't seem to find an easy way of stripping the quoting added by the quote method. 但是,当我从数据库中提取数据时,仍然使用MDB2,我似乎找不到一种简单的方法来删除quote方法所添加的引用。 At the moment I am using the stripslashes, but this doesn't seem right. 目前,我正在使用反斜杠,但这似乎并不正确。 Am I missing a setting somewhere? 我在某处缺少设置吗? I am I using the package in the wrong way? 我使用包装的方式有误吗?
Thank you for you help, Leif 谢谢您的帮助,莱夫
I've found that turning off magic_quotes_gpc
, and magic_quotes_runtime
, to be the best approach. 我发现关闭magic_quotes_gpc
和magic_quotes_runtime
是最好的方法。 In fact, as of 5.3.0
these directives have been deprecated. 实际上,从5.3.0
这些指令已被弃用。 In 6.0
they have been removed all together. 在6.0
它们已全部删除。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.