如何在magento中使用mysql进行转义? [英] How to mysql escape in magento?

查看:77
本文介绍了如何在magento中使用mysql进行转义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在magento中转义字符串,但是当我使用mysql_real_escape_string时,我得到警告.

I want to escape string in magento, but when I am using mysql_real_escape_string, i am getting warning.

警告:mysql_real_escape_string() [function.mysql-real-escape-string]:无法连接到本地MySQL 服务器通过套接字'/var/lib/mysql/mysql.soc .....'

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.soc.....'

我找不到任何magento的核心mysql转义功能.那么,我该怎么办?

I couldn't find any magento's core mysql escape function. So, what should I do?

推荐答案

使用此代码可对查询进行转义并添加周围的单引号:

Use this to escape a string for a query and add the surrounding single quotes:

Mage::getSingleton('core/resource')->getConnection('default_write')->quote($string);

如果需要,您可以查询Varien_Db_Adapter_Pdo_Mysql以获取更多报价详细信息.

You can look up Varien_Db_Adapter_Pdo_Mysql for further quoting details if needed.

这篇关于如何在magento中使用mysql进行转义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆