esc_sql

函式
esc_sql ( $data )
引數
  • (string|array) $data Unescaped data.
    Required:
返回值
  • (string|array) Escaped data, in the same type as supplied.
定義位置
相關方法
esc_jsesc_urlesc_xmlesc_htmlis_ssl
引入
2.8.0
棄用
-

esc_sql: 這個函式用來轉義一個字串,以便在SQL查詢中使用。

釋放資料以便在MySQL查詢中使用。

通常,你應該使用wpdb::prepare()來準備查詢。有時,現場轉義是必要的或有用的。一個例子是準備一個陣列以用於IN子句中。

注意:從4.8.3開始,’%’字元將被替換成一個佔位符字串,這可以防止某些SQLi攻擊的發生。這種行為的改變可能會給那些期望esc_sql()的返回值可用於其他目的的程式碼帶來問題。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function esc_sql( $data ) {
global $wpdb;
return $wpdb->_escape( $data );
}
function esc_sql( $data ) { global $wpdb; return $wpdb->_escape( $data ); }
function esc_sql( $data ) {
	global $wpdb;
	return $wpdb->_escape( $data );
}

常見問題

FAQs
檢視更多 >