本文整理汇总了PHP中resource::real_escape_string方法的典型用法代码示例。如果您正苦于以下问题:PHP resource::real_escape_string方法的具体用法?PHP resource::real_escape_string怎么用?PHP resource::real_escape_string使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类resource
的用法示例。
在下文中一共展示了resource::real_escape_string方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: escape_string
/**
* 过滤数据
* @return void
*/
public function escape_string($string, $master_or_slave = 'slave')
{
$this->checkLink($master_or_slave);
if (!$this->link) {
return $this->_error(90311, "数据库连接失败");
}
return $this->link->real_escape_string($string);
}
示例2: _parseValue
/**
* 过滤值
*
* @param string $value
* @return string
*/
protected function _parseValue($value)
{
// if (!get_magic_quotes_gpc()) {
// return addslashes($value);
// }
// return $value;
return $this->_link->real_escape_string($value);
}
示例3: escape
/**
* Escapes variables/data in order to make it safe to use in a MySQL query
*
* @param string $str | The string to escape
* @return string/boolean | Returns the escaped string on success / FALSE on failure
*/
public function escape($str)
{
if (!$this->isConnected) {
$rc = $this->createConnection();
if ($rc === FALSE) {
return FALSE;
}
}
return $this->mysqli->real_escape_string($str);
}
示例4: escape
/**
* @param string $value
* @return string
*/
public function escape($value)
{
if (is_array($value)) {
$dump = var_export($value, true);
$message = 'aMySQLi class error: Try to escape non-string value: ' . $dump;
$error = new AError($message);
$error->toLog()->toDebug()->toMessages();
return false;
}
return $this->connection->real_escape_string((string) $value);
}
示例5: esc
/**
* Escapes special characters in a string for use in an SQL statement
*
* @param string $value Value to be escaped
* @param mixed $with_aphostrophe
* @return string
*/
public function esc($value, $with_aphostrophe = "'")
{
// To avoid sql injection
$value = $this->mysqli->real_escape_string($value);
// If `$with_aphostrophe` parameter is specified and it is string then use it
$a = $with_aphostrophe ? is_string($with_aphostrophe) ? $with_aphostrophe : "'" : '';
if ($with_aphostrophe) {
$value = $a . $value . $a;
}
return $value;
}
示例6: escapeAll
/**
* Escape all faulty characters in the query
* @param type $str
* @return resource
*/
public function escapeAll($str)
{
$str = str_replace("%", "", $str);
if ($this->db_type == "mysqli") {
return $this->link_id->real_escape_string($str);
} else {
if ($this->db_type == "mysql") {
return mysql_escape_string($str);
}
}
}
示例7: escape
public function escape($string)
{
if (get_magic_quotes_runtime()) {
$string = stripslashes($string);
}
if (function_exists($this->db->real_escape_string)) {
return $this->db->real_escape_string($string);
} elseif (function_exists($this->db->quote)) {
return $this->db->quote($string);
} else {
return $string;
}
}
示例8: addslashes
public function addslashes($value)
{
return $this->dbConn->real_escape_string($value);
}
示例9: _escape
/**
* Escape a string for the database
*
* @param string $str
* @return string
*/
protected function _escape($str)
{
if (is_array($str)) {
error_log('Param passed to _escape($str) was an array: ' . print_r($str, true));
$str = '';
}
return $this->_conn->real_escape_string($str);
}
示例10: _escape
/**
* Escape a string for the database
*
* @param string $str
* @return string
*/
protected function _escape($str)
{
return $this->_conn->real_escape_string($str);
}
示例11: escape
/**
* Escape a value to use it in a query
*
* @see inc/classes/db/MsdDbFactory#escape($val)
* @param mixed $val The value to escape
*
* @return mixed
*/
public function escape($val)
{
return $this->_mysqli->real_escape_string($val);
}