如何在复合键方案中构造迁移SQLMap

时间:2012-12-19 07:19:16

标签: drupal-7 migrate

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

1 个答案:

答案 0 :(得分: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')
);

在上面的代码中,* vendor_code *和* client_code *是复合键的组成部分。