Automattic\WooCommerce\Admin\API\Reports

DataStore::get_object_where_filter()protectedWC 1.0

Get WHERE filter by object ids subquery.

Method of the class: DataStore{}

No Hooks.

Return

String.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_object_where_filter( $select_table, $select_field, $filter_table, $filter_field, $compare, $id_list );
$select_table(string) (required)
Select table name.
$select_field(string) (required)
Select table object ID field name.
$filter_table(string) (required)
Lookup table name.
$filter_field(string) (required)
Lookup table object ID field name.
$compare(string) (required)
Comparison string (IN|NOT IN).
$id_list(string) (required)
Comma separated ID list.

DataStore::get_object_where_filter() code WC 8.7.0

protected function get_object_where_filter( $select_table, $select_field, $filter_table, $filter_field, $compare, $id_list ) {
	global $wpdb;
	if ( empty( $id_list ) ) {
		return '';
	}

	$lookup_name = isset( $wpdb->$filter_table ) ? $wpdb->$filter_table : $wpdb->prefix . $filter_table;
	// phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared
	return " {$select_table}.{$select_field} {$compare} (
		SELECT
			DISTINCT {$filter_table}.{$select_field}
		FROM
			{$filter_table}
		WHERE
			{$filter_table}.{$filter_field} IN ({$id_list})
	)";
	// phpcs:enable WordPress.DB.PreparedSQL.InterpolatedNotPrepared
}