You are here

public function MigrationBase::getLastImported in Migrate 7.2

Same name and namespace in other branches
  1. 6.2 includes/base.inc \MigrationBase::getLastImported()

Retrieve the last time an import operation completed successfully.

Return value

string Date/time string, formatted... How? Default DB server format?

File

includes/base.inc, line 803
Defines the base class for migration processes.

Class

MigrationBase
The base class for all objects representing distinct steps in a migration process. Most commonly these will be Migration objects which actually import data from a source into a Drupal destination, but by deriving classes directly from MigrationBase…

Code

public function getLastImported() {
  $last_imported = db_select('migrate_log', 'ml')
    ->fields('ml', array(
    'endtime',
  ))
    ->condition('machine_name', $this->machineName)
    ->isNotNull('endtime')
    ->orderBy('endtime', 'DESC')
    ->range(0, 1)
    ->execute()
    ->fetchField();
  if ($last_imported) {
    $last_imported = date('Y-m-d H:i:s', $last_imported / 1000);
  }
  else {
    $last_imported = '';
  }
  return $last_imported;
}