Automattic\WooCommerce\Internal\DataStores\Orders

OrdersTableMetaQuery::generate_join_for_clause()privateWC 1.0

Generates a JOIN clause to handle an atomic meta_query clause.

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

Хуков нет.

Возвращает

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

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

// private - только в коде основоного (родительского) класса
$result = $this->generate_join_for_clause( $clause, $alias ): string;
$clause(массив) (обязательный)
An atomic meta_query clause.
$alias(строка) (обязательный)
Metadata table alias to use.

Код OrdersTableMetaQuery::generate_join_for_clause() WC 6.9.4

private function generate_join_for_clause( array $clause, string $alias ): string {
	global $wpdb;

	if ( 'NOT EXISTS' === $clause['compare'] ) {
		if ( 'LIKE' === $clause['compare_key'] ) {
			return $wpdb->prepare(
				"LEFT JOIN {$this->meta_table} AS {$alias} ON ( {$this->orders_table}.id = {$alias}.order_id AND {$alias}.meta_key LIKE %s )", // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
				'%' . $wpdb->esc_like( $clause['key'] ) . '%'
			);
		} else {
			return $wpdb->prepare(
				"LEFT JOIN {$this->meta_table} AS {$alias} ON ( {$this->orders_table}.id = {$alias}.order_id AND {$alias}.meta_key = %s )", // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
				$clause['key']
			);
		}
	}

	return "INNER JOIN {$this->meta_table} AS {$alias} ON ( {$this->orders_table}.id = {$alias}.order_id )";
}