Automattic\WooCommerce\Database\Migrations

MetaToCustomTableMigrator::fetch_data_for_migration_for_ids()privateWC 1.0

Fetch data for migration.

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

Хуков нет.

Возвращает

Массив[]. Data along with errors (if any), will of the form: array( 'data' => array(

'id_1' => array( 'column1' => value1, 'column2' => value2, ...),
...,

), 'errors' => array(

'id_1' => array( 'column1' => error1, 'column2' => value2, ...),
...,

)

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

// private - только в коде основоного (родительского) класса
$result = $this->fetch_data_for_migration_for_ids( $entity_ids ): array;
$entity_ids(массив) (обязательный)
Entity IDs to fetch data for.

Код MetaToCustomTableMigrator::fetch_data_for_migration_for_ids() WC 8.7.0

private function fetch_data_for_migration_for_ids( array $entity_ids ): array {
	if ( empty( $entity_ids ) ) {
		return array(
			'data'   => array(),
			'errors' => array(),
		);
	}

	$entity_table_query = $this->build_entity_table_query( $entity_ids );
	// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Output of $this->build_entity_table_query is already prepared.
	$entity_data = $this->db_get_results( $entity_table_query );
	if ( empty( $entity_data ) ) {
		return array(
			'data'   => array(),
			'errors' => array(),
		);
	}
	$entity_meta_rel_ids = array_column( $entity_data, 'entity_meta_rel_id' );

	$meta_table_query = $this->build_meta_data_query( $entity_meta_rel_ids );
	// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Output of $this->build_meta_data_query is already prepared.
	$meta_data = $this->db_get_results( $meta_table_query );

	return $this->process_and_sanitize_data( $entity_data, $meta_data );
}