esc_sql

函数


esc_sql ( $data )
参数
  • (string|array)
    $data
    Unescaped data.
    Required:
返回值
  • (string|array) Escaped data, in the same type as supplied.
定义位置
  • wp-includes/formatting.php
    , line 4348
引入
2.8.0
弃用

Escapes data for use in a MySQL query.

Usually you should prepare queries using wpdb::prepare().
Sometimes, spot-escaping is required or useful. One example
is preparing an array for use in an IN clause.

NOTE: Since 4.8.3, ‘%’ characters will be replaced with a placeholder string,
this prevents certain SQLi attacks from taking place. This change in behavior
may cause issues for code that expects the return value of esc_sql() to be useable
for other purposes.

function esc_sql( $data ) {
	global $wpdb;
	return $wpdb->_escape( $data );
}