Automattic\WooCommerce\Internal\DataStores\Orders

OrdersTableMetaQuery::is_operator_compatible_with_shared_join()privateWC 1.0

Checks whether two meta_query clauses can share a JOIN.

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

Хуков нет.

Возвращает

true|false. TRUE if the clauses can share a table alias, FALSE otherwise.

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

// private - только в коде основоного (родительского) класса
$result = $this->is_operator_compatible_with_shared_join( $clause, $sibling, $relation ): bool;
$clause(массив) (обязательный)
An atomic meta_query clause.
$sibling(массив) (обязательный)
An atomic meta_query clause.
$relation(строка)
The relation involving both clauses.
По умолчанию: 'AND'

Код OrdersTableMetaQuery::is_operator_compatible_with_shared_join() WC 8.7.0

private function is_operator_compatible_with_shared_join( array $clause, array $sibling, string $relation = 'AND' ): bool {
	if ( ! $this->is_atomic( $clause ) || ! $this->is_atomic( $sibling ) ) {
		return false;
	}

	$valid_operators = array();

	if ( 'OR' === $relation ) {
		$valid_operators = array( '=', 'IN', 'BETWEEN', 'LIKE', 'REGEXP', 'RLIKE', '>', '>=', '<', '<=' );
	} elseif ( isset( $sibling['key'] ) && isset( $clause['key'] ) && $sibling['key'] === $clause['key'] ) {
		$valid_operators = array( '!=', 'NOT IN', 'NOT LIKE' );
	}

	return in_array( strtoupper( $clause['compare'] ), $valid_operators, true ) && in_array( strtoupper( $sibling['compare'] ), $valid_operators, true );
}