3

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

4

1 回答 1

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* 是组合键的组成部分。

于 2013-04-24T16:03:13.620 回答