WP_Meta_Query::__construct()publicWP 3.2.0

Constructor.

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

Хуков нет.

Возвращает

null. Ничего (null).

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

$WP_Meta_Query = new WP_Meta_Query();
$WP_Meta_Query->__construct( $meta_query );
$meta_query(массив)

Array of meta query clauses. When first-order clauses or sub-clauses use strings as their array keys, they may be referenced in the 'orderby' parameter of the parent query.

По умолчанию: false

  • relation(строка)
    Optional. The MySQL keyword used to join the clauses of the query. Accepts 'AND' or 'OR'.
    По умолчанию: 'AND'

  • ...$0(массив)
    Optional. An array of first-order clause parameters, or another fully-formed meta query.

    • key(строка|string[])
      Meta key or keys to filter by.

    • compare_key(строка)
      MySQL operator used for comparing the $key. Accepts:

      • '='
      • '!='
      • 'LIKE'
      • 'NOT LIKE'
      • 'IN'
      • 'NOT IN'
      • 'REGEXP'
      • 'NOT REGEXP'
      • 'RLIKE',
      • 'EXISTS' (alias of '=')
      • 'NOT EXISTS' (alias of '!=') Default is 'IN' when $key is an array, '=' otherwise.
    • type_key(строка)
      MySQL data type that the meta_key column will be CAST to for comparisons. Accepts 'BINARY' for case-sensitive regular expression comparisons.
      По умолчанию: ''

    • value(строка|string[])
      Meta value or values to filter by.

    • compare(строка)
      MySQL operator used for comparing the $value. Accepts:

      • '=',
      • '!='
      • '>'
      • '>='
      • '<'
      • '<='
      • 'LIKE'
      • 'NOT LIKE'
      • 'IN'
      • 'NOT IN'
      • 'BETWEEN'
      • 'NOT BETWEEN'
      • 'REGEXP'
      • 'NOT REGEXP'
      • 'RLIKE'
      • 'EXISTS'
      • 'NOT EXISTS' Default is 'IN' when $value is an array, '=' otherwise.
    • type(строка)
      MySQL data type that the meta_value column will be CAST to for comparisons. Accepts:

      • 'NUMERIC'
      • 'BINARY'
      • 'CHAR'
      • 'DATE'
      • 'DATETIME'
      • 'DECIMAL'
      • 'SIGNED'
      • 'TIME'
      • 'UNSIGNED' Default is 'CHAR'.

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

С версии 3.2.0 Введена.
С версии 4.2.0 Introduced support for naming query clauses by associative array keys.
С версии 5.1.0 Introduced $compare_key clause parameter, which enables LIKE key matches.
С версии 5.3.0 Increased the number of operators available to $compare_key. Introduced $type_key, which enables the $key to be cast to a new data type for comparisons.

Код WP_Meta_Query::__construct() WP 6.5.2

public function __construct( $meta_query = false ) {
	if ( ! $meta_query ) {
		return;
	}

	if ( isset( $meta_query['relation'] ) && 'OR' === strtoupper( $meta_query['relation'] ) ) {
		$this->relation = 'OR';
	} else {
		$this->relation = 'AND';
	}

	$this->queries = $this->sanitize_query( $meta_query );
}