function migrate_add_mapping in Migrate 6
Add a mapping from source ID to destination ID for the specified content set
Parameters
$mcsid: ID of the content set being processed
$sourceid: Primary key value from the source
$destid: Primary key value from the destination
5 calls to migrate_add_mapping()
- comment_migrate_complete_comment in modules/
comment.migrate.inc - Implementation of hook_migrate_complete_comment().
- node_migrate_import_node in modules/
node.migrate.inc - Implementation of hook_migrate_import_node().
- taxonomy_migrate_import_term in modules/
taxonomy.migrate.inc - Implementation of hook_migrate_import_term().
- user_migrate_import_role in modules/
user.migrate.inc - Implementation of hook_migrate_import_role().
- user_migrate_import_user in modules/
user.migrate.inc - Implementation of hook_migrate_import_user().
File
- ./
migrate.module, line 359 - This module provides tools at "administer >> content >> migrate" for analyzing data from various sources and importing them into Drupal tables.
Code
function migrate_add_mapping($mcsid, $sourceid, $destid) {
static $maptables = array();
if (!isset($maptables[$mcsid])) {
$maptables[$mcsid] = migrate_map_table_name($mcsid);
}
$needs_update = db_result(db_query('SELECT needs_update
FROM {' . $maptables[$mcsid] . "}\n WHERE sourceid='%s'", $sourceid));
if ($needs_update == 1) {
db_query('UPDATE {' . $maptables[$mcsid] . "}\n SET needs_update=0\n WHERE sourceid='%s'", $sourceid);
}
elseif ($needs_update !== 0) {
db_query('INSERT INTO {' . $maptables[$mcsid] . "}\n (sourceid, destid, needs_update)\n VALUES('%s', %d, 0)", $sourceid, $destid);
}
}