本文整理匯總了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);
}