get_meta_sql

函式
get_meta_sql ( $meta_query, $type, $primary_table, $primary_id_column, $context = null )
引數
  • (array) $meta_query A meta query.
    Required:
  • (string) $type Type of meta.
    Required:
  • (string) $primary_table Primary database table name.
    Required:
  • (string) $primary_id_column Primary ID column name.
    Required:
  • (object) $context Optional. The main query object
    Required:
    Default: null
返回值
  • (string[]|false) { Array containing JOIN and WHERE SQL clauses to append to the main query, or false if no table exists for the requested meta type. @type string $join SQL fragment to append to the main JOIN clause. @type string $where SQL fragment to append to the main WHERE clause. }
相關
  • WP_Meta_Query
定義位置
相關方法
get_tax_sqlget_meta_keys_get_meta_tableget_tagsget_comments
引入
3.2.0
棄用
-

get_meta_sql函式用於生成可用於查詢WordPress資料庫中後設資料的SQL條款: 這個函式可以用來對後設資料進行自定義查詢。

給定一個元查詢,生成SQL條款,附加到主查詢中。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function get_meta_sql( $meta_query, $type, $primary_table, $primary_id_column, $context = null ) {
$meta_query_obj = new WP_Meta_Query( $meta_query );
return $meta_query_obj->get_sql( $type, $primary_table, $primary_id_column, $context );
}
function get_meta_sql( $meta_query, $type, $primary_table, $primary_id_column, $context = null ) { $meta_query_obj = new WP_Meta_Query( $meta_query ); return $meta_query_obj->get_sql( $type, $primary_table, $primary_id_column, $context ); }
function get_meta_sql( $meta_query, $type, $primary_table, $primary_id_column, $context = null ) {
	$meta_query_obj = new WP_Meta_Query( $meta_query );
	return $meta_query_obj->get_sql( $type, $primary_table, $primary_id_column, $context );
}

常見問題

FAQs
檢視更多 >