Automattic\WooCommerce\Database\Migrations
MetaToCustomTableMigrator::fetch_data_for_migration_for_ids
Fetch data for migration.
Method of the class: MetaToCustomTableMigrator{}
No Hooks.
Returns
Array[]. 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, ...), ...,
)
Usage
// private - for code of main (parent) class only $result = $this->fetch_data_for_migration_for_ids( $entity_ids ): array;
- $entity_ids(array) (required)
- Entity IDs to fetch data for.
MetaToCustomTableMigrator::fetch_data_for_migration_for_ids() MetaToCustomTableMigrator::fetch data for migration for ids code WC 10.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 );
}