get_meta_sql()
get_meta_sql( array $meta_query, string $type, string $primary_table, string $primary_id_column, object $context = null )
给定一个元查询,生成要附加到主查询的SQL子句。
Given a meta query, generates SQL clauses to be appended to a main query.
说明(Description)
另见函数 https://www.wp2.cn/functions()
参数(Parameters)
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
$meta_query | (array) | 必需 | 元查询。 |
$type | (string) | 必需 | 元类型。 |
$primary_table | (string) | 必需 | 主数据库表名。 |
$primary_id_column | (string) | 必需 | 主ID列名。 |
$context | (object) | 可选 | 主查询对象 |
返回(Return)
(array)JOIN和WHERE SQL的关联数组。
源码(Source)
/** * Given a meta query, generates SQL clauses to be appended to a main query. * * @since 3.2.0 * * @see WP_Meta_Query * * @param array $meta_query A meta query. * @param string $type Type of meta. * @param string $primary_table Primary database table name. * @param string $primary_id_column Primary ID column name. * @param object $context Optional. The main query object * @return array Associative array of `JOIN` and `WHERE` SQL. */ 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 ); }
更新版本 | 源码位置 | 使用 | 被使用 |
---|---|---|---|
3.2.0 | wp-includes/meta.php:1009 | 0 | 1 function |
笔记(Notes)
例子
get_meta_sql() 为WP2原创文章,链接:https://www.wp2.cn/functions/get_meta_sql/