wordpress 函数:esc-云顶国际

$wpdb->_escape() 的别名,用于进行 sql 查询之前的字符串处理。

用法

参数

$string
(string) (required) 一条转义的 sql 查询语句。
default: none

返回值

(string) 
转义之后适合 sql 查询中使用的字符串。

实例

$name=esc_sql($name);
$status=esc_sql($status);
$wpdb->get_var( 
  "select something from table where foo = '$name' and status = '$status'"
);

注解

sql 转义还是建议首选 $wpdb->prepare(),因为它可以修正一些格式方面的错误。

修改记录

since: 2.8.0

源文件

wp-includes/formatting.php

         
网站地图