如果表有复合主键,我们如何实例化MigrateSQLMap?
答案 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 *是复合键的组成部分。