get_meta_sql() WordPress Function

The get_meta_sql() function is used to generate SQL code for retrieving post meta data from the database. This function is used internally by the Wordpress database abstraction layer to generate SQL queries.

get_meta_sql( array $meta_query, string $type, string $primary_table, string $primary_id_column, object $context = null ) #

Given a meta query, generates SQL clauses to be appended to a main query.


Description

Top ↑

See also


Top ↑

Parameters

$meta_query

(array)(Required)A meta query.

$type

(string)(Required)Type of meta.

$primary_table

(string)(Required)Primary database table name.

$primary_id_column

(string)(Required)Primary ID column name.

$context

(object)(Optional) The main query object

Default value: null


Top ↑

Return

(array) Associative array of JOIN and WHERE SQL.


Top ↑

Source

File: wp-includes/meta.php

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 );
}


Top ↑

Changelog

Changelog
VersionDescription
3.2.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.