Skip to content

Instantly share code, notes, and snippets.

@mneuhaus
Created December 3, 2015 13:12
Show Gist options
  • Save mneuhaus/bbd7a76d1a3070a6467a to your computer and use it in GitHub Desktop.
Save mneuhaus/bbd7a76d1a3070a6467a to your computer and use it in GitHub Desktop.
import tt_content and pages form another database
/* @var TYPO3\CMS\Core\Database\DatabaseConnection $db */;
$db = $GLOBALS['TYPO3_DB'];
$db->debugOutput = true;
$db->exec_DELETEquery('pages', 'pid = 125');
$db->exec_DELETEquery('tt_content', 'rowDescription = "import-tagged"');
$maxPageUid = $db->exec_SELECTgetSingleRow('MAX(uid) as max', 'pages', '1=1')['max'];
$maxFiletUid = $db->exec_SELECTgetSingleRow('MAX(uid) as max', 'sys_file', '1=1')['max'];
$pages = $db->exec_SELECTgetRows('*', 'pages_casestudies', 'deleted = 0 AND pid = 1');
$pageUids = array();
foreach ($pages as $page) {
$page['uid'] = $page['uid'] + $maxPageUid;
$pageUids[] = $page['uid'];
$page['pid'] = 125;
$db->exec_INSERTquery('pages', $page);
}
$rows = $db->exec_SELECTgetRows('*', 'tt_content_casestudies', 'deleted = 0');
$maxContentUid = $db->exec_SELECTgetSingleRow('MAX(uid) as max', 'tt_content', '1=1')['max'];
foreach ($rows as $row) {
$row['uid'] = $row['uid'] + $maxContentUid;
$row['pid'] = $row['pid'] + $maxPageUid;
$row['tx_flux_parent'] = $row['tx_flux_parent'] + $maxContentUid;
$row['rowDescription'] = 'import-tagged';
if ($row['tx_fed_fcefile'] == 'Famelo.Template:50-50.html') {
$row['tx_fed_fcefile'] = 'Famelo.Template:6-6.html';
}
if (!in_array($row['pid'], $pageUids)) {
continue;
}
$db->exec_INSERTquery('tt_content', $row);
}
exit();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment