Automattic\WooCommerce\Internal\DataStores\Orders

OrdersTableMetaQuery::flatten_where_clauses()privateWC 1.0

Flattens a nested WHERE array.

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

Хуков нет.

Возвращает

Строку. An SQL WHERE clause.

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

// private - только в коде основоного (родительского) класса
$result = $this->flatten_where_clauses( $where ): string;
$where(массив) (обязательный)
A possibly nested WHERE array with AND/OR operators.

Код OrdersTableMetaQuery::flatten_where_clauses() WC 8.7.0

private function flatten_where_clauses( $where ): string {
	if ( is_string( $where ) ) {
		return trim( $where );
	}

	$chunks   = array();
	$operator = $this->sanitize_relation( $where['operator'] ?? '' );

	foreach ( $where as $key => $w ) {
		if ( 'operator' === $key ) {
			continue;
		}

		$flattened = $this->flatten_where_clauses( $w );
		if ( $flattened ) {
			$chunks[] = $flattened;
		}
	}

	if ( $chunks ) {
		return '(' . implode( " {$operator} ", $chunks ) . ')';
	} else {
		return '';
	}
}