如何在复合键场景中构造MigrateSQLMap

mis*_*hka 3 migrate drupal-7

如果表具有复合主键,我们如何实例化MigrateSQLMap?

Man*_*anu 5

当MigrateSQLMap采用数组时,您可以在源定义中设置多个字段:

// The source ID here is the one retrieved from each data item in the XML file, and
// used to identify specific items
$this->map = new MigrateSQLMap($this->machineName,
  array(
    'vendor_code' => array(
      'type' => 'varchar',
      'length' => 250,
      'not null' => TRUE,
    ),
    'client_code' => array(
      'type' => 'varchar',
      'length' => 250,
      'not null' => TRUE,
    ),
  ),
  MigrateDestinationEntityAPI::getKeySchema('vendor')
);
Run Code Online (Sandbox Code Playgroud)

在上面的代码中,*vendor_code*和*client_code*是组合键的组件.