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 に答える