esc_sql( string|array $data )

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.

参数

$data

(string|array)

(Required)

Unescaped data

返回值

(string|array) Escaped data

源代码

File: wp-includes/formatting.php

function esc_sql( $data ) {

global $wpdb;

return $wpdb->_escape( $data );

}

更新日志

Version

描述

2.8.0

Introduced.

相关函数

Uses

wp-includes/wp-db.php:

wpdb::_escape()

Used By

wp-includes/class-wp-user-query.php:

WP_User_Query::parse_orderby()

wp-includes/class-wp-comment-query.php:

WP_Comment_Query::parse_orderby()

wp-includes/date.php:

WP_Date_Query::get_sql_for_clause()

wp-includes/class-wp-query.php:

WP_Query::get_posts()

wp-includes/class-wp-tax-query.php:

WP_Tax_Query::transform_query()

wp-includes/taxonomy.php:

_pad_term_counts()

wp-includes/taxonomy.php:

_update_post_term_count()

wp-includes/date.php:

WP_Date_Query::__construct()

wp-includes/post.php:

get_page_by_path()

wp-includes/post.php:

get_page_by_title()

Show 5 more used by

Hide more used by

User Contributed Notes

Skip to note content

You must log in to vote on the helpfulness of this noteVote results for this note: 1You must log in to vote on the helpfulness of this note

Contributed by J.D. Grimes

It should be noted that this function will only escape values to be used in strings in the query. That is, it only provides escaping for values that will be within quotes in the SQL (as in field = '{$escaped_value}'). If your value is not going to be within quotes, your code will still be vulnerable to SQL injection. For example, this is vulnerable, because the escaped value is not surrounded by quotes in the SQL query: ORDER BY {$escaped_value}. As such, this function does not escape unquoted numeric values, field names, or SQL keywords..

Basic Example

$name = esc_sql( $name );

$status = esc_sql( $status );

$wpdb->get_var( "SELECT something FROM table WHERE foo = '$name' and status = '$status'" );

?>

escilpe mysql,wordpress函数esc_sql()用法示例相关推荐

  1. PHP Calendar 函数,wordpress函数get_calendar()用法示例

    get_calendar( bool $initial = true, bool $echo = true ) Display calendar with days that have posts a ...

  2. php中mimes函数,wordpress函数check_upload_mimes()用法示例

    check_upload_mimes( array $mimes ) Check an array of MIME types against a whitelist. 描述 WordPress sh ...

  3. MySQL自定义函数简单用法示例

    点击新建函数 比如我要创建一个求平方和的函数 选择是否添加参数,可以选择参数类型 选择返回的属性的类型 这是自定义函数的语法 CREATE FUNCTION <函数名> ( [ <参 ...

  4. php getfooter,wordpress函数get_footer()用法示例

    get_footer( string $name = null ) Load footer template. 描述 Includes the footer template for a theme ...

  5. add php support,wordpress函数add_post_type_support()用法示例

    add_post_type_support( string $post_type, string|array $feature ) Register support of certain featur ...

  6. php geteditor,wordpress函数get_editor_stylesheets()用法示例

    get_editor_stylesheets() Retrieve any registered editor stylesheets 描述 返回值 (array) If registered, a ...

  7. php函数clean(),wordpress函数clean_url()用法示例

    Warning: This function has been deprecated. Use esc_url() instead. clean_url( string $url, array $pr ...

  8. ?php get_sidebar(); ?,wordpress函数get_sidebar()用法示例

    get_sidebar( string $name = null ) Load sidebar template. 描述 Includes the sidebar template for a the ...

  9. html class函数,wordpress函数sanitize_html_class()用法示例

    sanitize_html_class( string $class, string $fallback = '' ) Sanitizes an HTML classname to ensure it ...

最新文章

  1. extjs中滚动条属性_十分钟快速了解 JS 中的 offset、scroll、client
  2. php header
  3. 相似三角形_JAVA
  4. 慕课网Spark SQL日志分析 - 4.从Hive平滑过渡到Spark SQL
  5. android 属性动画伸缩,Android的属性动画(二)加载框圆点旋转收缩放大缩小效果的实现...
  6. 年薪50万的Python架构师 不是梦
  7. And Then There Was One POJ - 3517(变形约瑟夫环+规律)
  8. Linux(CentOS)网络流量实时监控(iftop)
  9. QGraphicsView,QGraphicsScene,QGraphicsItem
  10. treemap底层结构_HashMap面试必问的数据结构相关知识总结
  11. 金蝶移动bos开发教程_移动BOS开发 -- 移动表单
  12. 七甲川荧光染料IR820 NHS ester,新吲哚菁绿-活化酯,New Indocyanine Green-nhs ester
  13. 图书管理系统mysql课程设计C_数据库课程设计 图书管理系统 附源代码.doc
  14. 单片机延时C语言程序
  15. 接口测试之协议和常用工具安装使用
  16. .7z.001 这种让人头疼的分卷格式
  17. 关于vc隐藏浏览器控件 2010-9-7 16:07
  18. 清华大学提出APDrawingGAN:人脸照片秒变艺术肖像画,已被CVPR 2019录取
  19. OKR 年度规划实践:如何在 2022 年做好准备
  20. 猜拳游戏python实现

热门文章

  1. 理一理字节对齐的那些事
  2. java(线程池的创建方式,和线程池的原理)
  3. [Python 网络编程] TCP、简单socket模拟ssh (一)
  4. Python day16(JavaScript)
  5. IOS开发之Storyboard应用
  6. [置顶] 基于遗传算法求解车辆路径问题
  7. 关于AI Architecture未来的一些思考
  8. CVPR2021 P2GAN:提高图像风格迁移的鲁棒性
  9. 近期机器学习竞赛汇总~总奖池超三百万人民币!
  10. CVPR 2019 | 旷视提出超分辨率新方法Meta-SR:单一模型实现任意缩放因子