You are here

public function Table::flushInserts in Migrate Plus 8.5

Execute the insert query and reset everything.

3 calls to Table::flushInserts()
Table::import in src/Plugin/migrate/destination/Table.php
Import the row.
Table::postImport in src/Plugin/migrate/destination/Table.php
Performs post-import tasks.
Table::__destruct in src/Plugin/migrate/destination/Table.php
Make absolutely sure batched inserts are processed (especially for stubs).

File

src/Plugin/migrate/destination/Table.php, line 272

Class

Table
Provides table destination plugin.

Namespace

Drupal\migrate_plus\Plugin\migrate\destination

Code

public function flushInserts() {
  if (count($this->rowsToInsert) > 0) {
    $batch_query = $this->dbConnection
      ->insert($this->tableName)
      ->fields(array_keys($this->rowsToInsert[0]));
    foreach ($this->rowsToInsert as $row) {
      $batch_query
        ->values(array_values($row));
    }

    // Empty the queue first, so if the statement throws an error we don't
    // end up here trying to execute the same statement (plus one row).
    $this->rowsToInsert = [];
    $batch_query
      ->execute();
  }
}