本文整理汇总了PHP中MDB2_Driver_Common::escape方法的典型用法代码示例。如果您正苦于以下问题:PHP MDB2_Driver_Common::escape方法的具体用法?PHP MDB2_Driver_Common::escape怎么用?PHP MDB2_Driver_Common::escape使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MDB2_Driver_Common
的用法示例。
在下文中一共展示了MDB2_Driver_Common::escape方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: escape
/**
* Quotes a string so it can be safely used in a query. It will quote
* the text so it can safely be used within a query.
*
* @param string $text the input string to quote
* @param bool $escape_wildcards flag
*
* @return string quoted string
* @access public
*/
function escape($text, $escape_wildcards = false)
{
$text = parent::escape($text, $escape_wildcards);
// http://pear.php.net/bugs/bug.php?id=16118
// http://support.microsoft.com/kb/164291
return preg_replace("/\\\\(\r\n|\r|\n)/", '\\\\$1', $text);
}
示例2: test_escape
/**
* Tests that the MDB2::escape() method correctly escapes strings.
*/
function test_escape()
{
$tmp = $this->db->string_quoting;
$this->string_quoting['escape'] = '\\';
$this->string_quoting['end'] = '"';
$text = 'xxx"z"xxx';
$this->assertEquals('xxx\\"z\\"xxx', MDB2_Driver_Common::escape($text), 'escape');
$this->db->string_quoting = $tmp;
}
示例3: escape
/**
* Quotes a string so it can be safely used in a query. It will quote
* the text so it can safely be used within a query.
*
* @param string the input string to quote
* @param bool escape wildcards
*
* @return string quoted string
*
* @access public
*/
function escape($text, $escape_wildcards = false)
{
//Remove a NULL-character (may break queries when inserted):
$text = str_replace("", '', $text);
return parent::escape($text, $escape_wildcards);
}