WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Платформа для конвертации и монетизации трафика
функция не описана

WP_Meta_Query::get_sql() public WP 3.2.0

Generates SQL clauses to be appended to a main query.

{} Это метод класса: WP_Meta_Query{}

Хуки из метода
Возвращает

Массив/false. Array containing JOIN and WHERE SQL clauses to append to the main query.

  • join(строка)
    SQL fragment to append to the main JOIN clause.

  • where(строка)
    SQL fragment to append to the main WHERE clause.

Использование

$WP_Meta_Query = new WP_Meta_Query();
$WP_Meta_Query->get_sql( $type, $primary_table, $primary_id_column, $context );
$type(строка) (обязательный)
Type of meta, eg 'user', 'post'.
$primary_table(строка) (обязательный)
Database table where the object being filtered is stored (eg wp_users).
$primary_id_column(строка) (обязательный)
ID column for the filtered object in $primary_table.
$context(объект)
The main query object.
По умолчанию: null

Список изменений

С версии 3.2.0 Введена.

Код WP_Meta_Query::get_sql() WP 5.5.3

<?php
public function get_sql( $type, $primary_table, $primary_id_column, $context = null ) {
	$meta_table = _get_meta_table( $type );
	if ( ! $meta_table ) {
		return false;
	}

	$this->table_aliases = array();

	$this->meta_table     = $meta_table;
	$this->meta_id_column = sanitize_key( $type . '_id' );

	$this->primary_table     = $primary_table;
	$this->primary_id_column = $primary_id_column;

	$sql = $this->get_sql_clauses();

	/*
	 * If any JOINs are LEFT JOINs (as in the case of NOT EXISTS), then all JOINs should
	 * be LEFT. Otherwise posts with no metadata will be excluded from results.
	 */
	if ( false !== strpos( $sql['join'], 'LEFT JOIN' ) ) {
		$sql['join'] = str_replace( 'INNER JOIN', 'LEFT JOIN', $sql['join'] );
	}

	/**
	 * Filters the meta query's generated SQL.
	 *
	 * @since 3.1.0
	 *
	 * @param array  $sql               Array containing the query's JOIN and WHERE clauses.
	 * @param array  $queries           Array of meta queries.
	 * @param string $type              Type of meta.
	 * @param string $primary_table     Primary table.
	 * @param string $primary_id_column Primary column ID.
	 * @param object $context           The main query object.
	 */
	return apply_filters_ref_array( 'get_meta_sql', array( $sql, $this->queries, $type, $primary_table, $primary_id_column, $context ) );
}