You are here

public function Sql::setUpdate in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/migrate/src/Plugin/migrate/id_map/Sql.php \Drupal\migrate\Plugin\migrate\id_map\Sql::setUpdate()
  2. 10 core/modules/migrate/src/Plugin/migrate/id_map/Sql.php \Drupal\migrate\Plugin\migrate\id_map\Sql::setUpdate()

Sets a specified record to be updated, if it exists.

Parameters

array $source_id_values: The source identifier values of the record.

Overrides MigrateIdMapInterface::setUpdate

File

core/modules/migrate/src/Plugin/migrate/id_map/Sql.php, line 836

Class

Sql
Defines the sql based ID map implementation.

Namespace

Drupal\migrate\Plugin\migrate\id_map

Code

public function setUpdate(array $source_id_values) {
  if (empty($source_id_values)) {
    throw new MigrateException('No source identifiers provided to update.');
  }
  $query = $this
    ->getDatabase()
    ->update($this
    ->mapTableName())
    ->fields([
    'source_row_status' => MigrateIdMapInterface::STATUS_NEEDS_UPDATE,
  ]);
  foreach ($this
    ->sourceIdFields() as $field_name => $source_id) {
    $query
      ->condition($source_id, $source_id_values[$field_name]);
  }
  $query
    ->execute();
}