WordPress at a glance

get_meta_sql() WP 1.0

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

Works based on: WP_Meta_Query()
✈ 1 time = 0.000172s = fast | 50000 times = 4.48s = fast

No Hooks.

Return

Array. Associative array of JOIN and WHERE SQL.

Usage

get_meta_sql( $meta_query, $type, $primary_table, $primary_id_column, $context );
$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)
The main query object
Default: null

Code of get_meta_sql: wp-includes/meta.php VER 4.9.8

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

Related Functions

From tag: sql

No comments
    Hello, !     Log In . Register