protected function MigrationBase::saveHighwater in Migrate 7.2
Same name and namespace in other branches
- 6.2 includes/base.inc \MigrationBase::saveHighwater()
Save the highwater mark for this migration (but not when using an idlist).
Parameters
mixed $highwater: Highwater mark to save
boolean $force: If TRUE, save even if it's lower than the previous value.
2 calls to MigrationBase::saveHighwater()
- Migration::import in includes/
migration.inc - Perform an import operation - migrate items from source to destination.
- Migration::rollback in includes/
migration.inc - Perform a rollback operation - remove migrated items from the destination.
File
- includes/
base.inc, line 844 - 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
protected function saveHighwater($highwater, $force = FALSE) {
if (!isset($this->options['idlist'])) {
$query = db_update('migrate_status')
->fields(array(
'highwater' => $highwater,
))
->condition('machine_name', $this->machineName);
if (!$force) {
if (!empty($this->highwaterField['type']) && $this->highwaterField['type'] == 'int') {
// If the highwater is an integer type, we need to force the DB server
// to treat the varchar highwater field as an integer (otherwise it will
// think '5' > '10').
switch (Database::getConnection()
->databaseType()) {
case 'pgsql':
$query
->where('(CASE WHEN highwater=\'\' THEN 0 ELSE CAST(highwater AS INTEGER) END) < :highwater', array(
':highwater' => intval($highwater),
));
break;
default:
// MySQL casts as integers as SIGNED or UNSIGNED.
$query
->where('(CASE WHEN highwater=\'\' THEN 0 ELSE CAST(highwater AS SIGNED) END) < :highwater', array(
':highwater' => intval($highwater),
));
}
}
else {
$query
->condition('highwater', $highwater, '<');
}
}
$query
->execute();
}
}