2 namespace TYPO3\CMS\Extensionmanager\Utility;
39 foreach ($dbFields as $table => $fields) {
40 if (is_array($dbFields[$table][
'fields'])) {
43 $insertStatements = $this->
dumpTableContent($table, $dbFields[$table][
'fields']);
44 $out .= $header . self::MULTI_LINEBREAKS . $tableHeader . self::MULTI_LINEBREAKS . $insertStatements . self::MULTI_LINEBREAKS;
58 # TYPO3 Extension Manager dump 1.1
60 # Host: ' . TYPO3_db_host .
' Database: ' . TYPO3_db .
'
61 #--------------------------------------------------------
73 protected function dumpTableHeader($table, array $fieldKeyInfo, $dropTableIfExists =
false)
78 if (is_array($fieldKeyInfo[
'fields'])) {
79 foreach ($fieldKeyInfo[
'fields'] as $fieldN => $data) {
80 $lines[] =
' ' . $fieldN .
' ' . $data;
84 if (is_array($fieldKeyInfo[
'keys'])) {
85 foreach ($fieldKeyInfo[
'keys'] as $fieldN => $data) {
86 $lines[] =
' ' . $data;
93 # Table structure for table "' . $table .
'"
95 ' . ($dropTableIfExists ?
'DROP TABLE IF EXISTS ' . $table .
';
96 ' :
'') .
'CREATE TABLE ' . $table .
' (
97 ' . implode((
',' . LF), $lines) .
'
116 $search = array(
'\\',
'\'',
"\0",
"\n",
"\r",
"\x1A");
117 $replace = array(
'\\\\',
'\\\'',
'\\0',
'\\n',
'\\r',
'\\Z');
120 $result =
$GLOBALS[
'TYPO3_DB']->exec_SELECTquery(
'*', $table,
'');
122 while ($row =
$GLOBALS[
'TYPO3_DB']->sql_fetch_assoc($result)) {
124 foreach ($fieldStructure as $field => $structure) {
125 $values[] = isset($row[$field]) ?
'\'' . str_replace($search, $replace, $row[$field]) .
'\'' :
'NULL';
127 $lines[] =
'INSERT INTO ' . $table .
' VALUES (' . implode(
', ', $values) .
');';
130 $GLOBALS[
'TYPO3_DB']->sql_free_result($result);
132 return implode(LF, $lines);