Automattic\WooCommerce\Database\Migrations
MetaToCustomTableMigrator::generate_update_sql_for_batch()
Generate SQL for data updating.
Метод класса: MetaToCustomTableMigrator{}
Хуков нет.
Возвращает
Строку
. Generated queries for batch update. Would be of the form: INSERT INTO $table ( $columns ) VALUES ($value for row 1) ($valye for row 2) ... ON DUPLICATE KEY UPDATE $column1 = VALUES($column1) $column2 = VALUES($column2) ...
Использование
// private - только в коде основоного (родительского) класса $result = $this->generate_update_sql_for_batch( $batch, $entity_row_mapping ): string;
- $batch(массив) (обязательный)
- Data to generate queries for. Will be data array returned by fetch_data_for_migration_for_ids() method.
- $entity_row_mapping(массив) (обязательный)
- Maps rows to update data with their original IDs. Will be returned by generate_update_sql_for_batch.
Код MetaToCustomTableMigrator::generate_update_sql_for_batch() MetaToCustomTableMigrator::generate update sql for batch WC 9.2.3
private function generate_update_sql_for_batch( array $batch, array $entity_row_mapping ): string { $table = $this->schema_config['destination']['table_name']; $destination_primary_id_schema = $this->get_destination_table_primary_id_schema(); foreach ( $batch as $entity_id => $row ) { $batch[ $entity_id ][ $destination_primary_id_schema['destination_primary_key']['destination'] ] = $entity_row_mapping[ $entity_id ]->destination_id; } list( $value_sql, $column_sql, $columns ) = $this->generate_column_clauses( array_merge( $destination_primary_id_schema, $this->core_column_mapping, $this->meta_column_mapping ), $batch ); $duplicate_update_key_statement = MigrationHelper::generate_on_duplicate_statement_clause( $columns ); return "INSERT INTO $table (`$column_sql`) VALUES $value_sql $duplicate_update_key_statement;"; }