- これは8 TYPO3 CMSまでを含む有効です。
$dataMap = ['<table-name>' => ['<record-uid>' => ['<field-name>' => '<field-value>']]
既存のレコードがレコードのuid
の整数値を使用しますフィールド、例えば123
、新しいレコードは、接頭辞がNEW
のランダムであるが一意の識別子を使用します。 uniqid('NEW', true)
によって作成されたNEWa2b3c4f8
- TYPO3 CMS 7 StringUtility::getUniqueId('NEW')
でも同様に使用できます。
一般的な例
のは、次のレコードが作成されなければならないと仮定しましょう: *表tt_content
に新しいコンテンツ要素*表sys_file_reference
のための2つの新しいインラインファイル参照フィールドのtt_content.image
UIDと既存のsys_file
レコードに参照+ 123
+ UID 234
$ttContentId = 'NEW58d5079c8741c8.22627844'; // uniqid('NEW', true)
$fileRefId1st = 'NEW58d506f3cd0c41.59344142'; // uniqid('NEW', true)
$fileRefId2nd = 'NEW58d50714c12260.92562338'; // uniqid('NEW', true)
と
sys_file
レコードを既存の参照これは、
NEWabc,NEWdef
、
123,234,345
又は
NEWabc,123,NEWdef
とすることができるいずれか - データマップ
HAVA、これは実際に新しいレコードまたは既存のレコードのカンマ区切り値によって定義された(新たな)インライン参照を、定義されtt_content.image
に近い外観準備
新しいレコードと既存のレコードを混在させる。あなたが作成されたレコードのuid
が必要な場合は、コマンドマップデータハンドラ
$dataHandler = new \TYPO3\CMS\Core\DataHandling\DataHandler();
$dataHandler->start($dataMap, $commandMap);
$dataHandler->process_datamap();
// $dataHandler->process_cmdmap(); // if $commandMap should be processed as well
を実行
// the command-maps is similar to the data-map to copy, localize, move records
// however, it's not required in this scenario and thus stays empty
$commandMap = [];
を準備
$dataMap = [
'tt_content' => [
'NEW58d5079c8741c8.22627844' => [
'title' => 'My new content element',
'bodytext' => 'Look at the following images...',
'CType' => 'textpic',
// $fileRefId1st & $fileRefId2nd, the sorting order is defined by this as well
'image' => 'NEW58d506f3cd0c41.59344142,NEW58d50714c12260.92562338',
],
],
'sys_file_reference' => [
'NEW58d506f3cd0c41.59344142' => [
'uid_local' => 123,
'title' => 'Image #123',
],
'NEW58d50714c12260.92562338' => [
'uid_local' => 234,
'title' => 'Image #234',
],
]
];
が、これは内部のDataHandlerレコードマッピングから解決することができます。たとえば、次のコードは、作成tt_content
レコードの新しいuid
を解決します
$ttContentId = $dataHandler->substNEWwithIDs['NEW58d5079c8741c8.22627844']; // e.g. 333
ノート
の参照を定義するだけでなく、NEW...
IDを含めることができ、フィールドtt_content.image
、のために上記の直接の例で起こります既存の整数ID。 (MM
無地)
- TCA型
inline
、全ての変異体について(普通、foreign_field
、MM
)
- TCA型
select
、全ての変異体について:の動作はTYPO3内のすべての参照型について同じですログエントリをDataHandler
性を保証してデータを渡すすべての亜種(プレーン、MM
)
ため
TCAタイプgroup
に、されていますほとんどの場合、TYPO3の履歴/ロールバックモジュールを使用して変更を元に戻すことができます。 さらに、大量のアクションを実行することもできます。DataHandler
の呼び出しは単なる集計に限られません(上記の例のtt_content
レコード)。ただし、NEW...
のIDは一意でなければならず、副作用を避けるために一括実行中に再使用してはなりません。最初の質問のtable_a
とtable_b
シナリオにこれを変革table_a
& table_b
シナリオ
に変身
、$dataMap
は以下のようになります。もちろんtable_b
への参照がtable_a
にバインドされているかどうかを判断する必要があります。
$dataMap = [
// existing records of table_a, thus using the real ids
'table_a' => [
'11' => [ 'reference_field' => 'NEW_b_1,NEW_b_2' ],
'22' => [ 'reference_field' => 'NEW_b_3,NEW_b_4' ],
'33' => [ 'reference_field' => 'NEW_b_5,NEW_b_6' ],
],
// new records to be references for table_b, thus using NEW... ids
'table_b' => [
'NEW_b_1' => [ ... field values of this particular table_b record ... ],
'NEW_b_2' => [ ... field values of this particular table_b record ... ],
'NEW_b_3' => [ ... field values of this particular table_b record ... ],
'NEW_b_4' => [ ... field values of this particular table_b record ... ],
'NEW_b_5' => [ ... field values of this particular table_b record ... ],
'NEW_b_6' => [ ... field values of this particular table_b record ... ],
],
];
データレコードをレコードで作成する必要はありませんが、大量実行のためには、これらの新しい「...」IDは一意であり、異なるレコードデータ。 –