Automattic\WooCommerce\Database\Migrations

MetaToCustomTableMigrator::get_where_clause_for_verification()protectedWC 1.0

Helper function to generate where clause for fetching data for verification.

Method of the class: MetaToCustomTableMigrator{}

No Hooks.

Return

String. WHERE clause.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_where_clause_for_verification( $source_ids );
$source_ids(array) (required)
Array of IDs from source table.

MetaToCustomTableMigrator::get_where_clause_for_verification() code WC 8.7.0

protected function get_where_clause_for_verification( $source_ids ) {
	global $wpdb;
	$source_primary_id_column = $this->schema_config['source']['entity']['primary_key'];
	$source_table             = $this->schema_config['source']['entity']['table_name'];
	$source_ids_placeholder   = implode( ', ', array_fill( 0, count( $source_ids ), '%d' ) );

	return $wpdb->prepare(
		// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare
		"$source_table.$source_primary_id_column IN ($source_ids_placeholder)",
		$source_ids
	);
}