Last active
October 18, 2018 15:10
-
-
Save politsin/1c3d55b25196b327762391fda75c9be5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Drupal\migration\Utility; | |
/** | |
* FeedsToMigration. | |
*/ | |
class InsertMigration { | |
/** | |
* Insert. | |
*/ | |
public static function insert($data, $table = 'migrate_map_********') { | |
$db = \Drupal::database(); | |
$fields = [ | |
'source_ids_hash', | |
'sourceid1', | |
'destid1', | |
'source_row_status', | |
'rollback_action', | |
'last_imported', | |
'hash', | |
]; | |
foreach ($data as $src => $dst) { | |
print "{$src} > {$dst}\n"; | |
$hash = hash('sha256', serialize(array_map('strval', [$src]))); | |
$line = [$hash, $src, $dst, 0, 0, 0, ""]; | |
// Insert the record to table. | |
$insert = $db->insert($table)->fields($fields)->values($line); | |
// $insert->execute(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment