/** * Outputs table's structure * * @param string $db database name * @param string $table table name * @param string $crlf the end of line sequence * @param string $error_url the url to go back in case of error * @param bool $relation whether to include relation comments * @param bool $comments whether to include the pmadb-style column comments * as comments in the structure; this is deprecated * but the parameter is left here because export.php * calls PMA_exportStructure() also for other export * types which use this parameter * @param bool $mime whether to include mime comments * @param bool $dates whether to include creation/update/check dates * @param string $export_mode 'create_table', 'triggers', 'create_view', 'stand_in' * @param string $export_type 'server', 'database', 'table' * @return bool Whether it succeeded * * @access public */ function PMA_exportStructure($db, $table, $crlf, $error_url, $relation = false, $comments = false, $mime = false, $dates = false, $export_mode, $export_type) { $formatted_table_name = isset($GLOBALS['sql_backquotes']) ? PMA_backquote($table) : '\'' . $table . '\''; $dump = PMA_possibleCRLF() . PMA_exportComment(str_repeat('-', 56)) . PMA_possibleCRLF() . PMA_exportComment(); switch ($export_mode) { case 'create_table': $dump .= PMA_exportComment(__('Table structure for table') . ' ' . $formatted_table_name); $dump .= PMA_exportComment(); $dump .= PMA_getTableDef($db, $table, $crlf, $error_url, $dates); $dump .= PMA_getTableComments($db, $table, $crlf, $relation, $mime); break; case 'triggers': $dump = ''; $triggers = PMA_DBI_get_triggers($db, $table); if ($triggers) { $dump .= PMA_possibleCRLF() . PMA_exportComment() . PMA_exportComment(__('Triggers') . ' ' . $formatted_table_name) . PMA_exportComment(); $delimiter = '//'; foreach ($triggers as $trigger) { $dump .= $trigger['drop'] . ';' . $crlf; $dump .= 'DELIMITER ' . $delimiter . $crlf; $dump .= $trigger['create']; $dump .= 'DELIMITER ;' . $crlf; } } break; case 'create_view': $dump .= PMA_exportComment(__('Structure for view') . ' ' . $formatted_table_name) . PMA_exportComment(); // delete the stand-in table previously created (if any) if ($export_type != 'table') { $dump .= 'DROP TABLE IF EXISTS ' . PMA_backquote($table) . ';' . $crlf; } $dump .= PMA_getTableDef($db, $table, $crlf, $error_url, $dates, true, true); break; case 'stand_in': $dump .= PMA_exportComment(__('Stand-in structure for view') . ' ' . $formatted_table_name) . PMA_exportComment(); // export a stand-in definition to resolve view dependencies $dump .= PMA_getTableDefStandIn($db, $table, $crlf); } // end switch // this one is built by PMA_getTableDef() to use in table copy/move // but not in the case of export unset($GLOBALS['sql_constraints_query']); return PMA_exportOutputHandler($dump); }
PMA_DBI_query($sql_drop_foreign_keys); } // keep the constraint we just dropped if (!empty($sql_constraints)) { $GLOBALS['sql_constraints_query_full_db'][] = $sql_constraints; } } unset($sql_constraints, $sql_drop_foreign_keys, $sql_structure); foreach ($tables_full as $each_table => $tmp) { // to be able to rename a db containing views, // first all the views are collected and a stand-in is created // the real views are created after the tables if (PMA_Table::isView($db, $each_table)) { $views[] = $each_table; // Create stand-in definition to resolve view dependencies $sql_view_standin = PMA_getTableDefStandIn($db, $each_table, "\n"); PMA_DBI_select_db($newname); PMA_DBI_query($sql_view_standin); $GLOBALS['sql_query'] .= "\n" . $sql_view_standin; } } foreach ($tables_full as $each_table => $tmp) { // skip the views; we have creted stand-in definitions if (PMA_Table::isView($db, $each_table)) { continue; } $back = $sql_query; $sql_query = ''; // value of $what for this table only $this_what = $what; // do not copy the data from a Merge table
/** * Outputs table's structure * * @param string $db database name * @param string $table table name * @param string $crlf the end of line sequence * @param string $error_url the url to go back in case of error * @param string $export_mode 'create_table', 'triggers', 'create_view', * 'stand_in' * @param string $export_type 'server', 'database', 'table' * @param bool $do_relation whether to include relation comments * @param bool $do_comments whether to include the pmadb-style column * comments as comments in the structure; * this is deprecated but the parameter is * left here because export.php calls * PMA_exportStructure() also for other * export types which use this parameter * @param bool $do_mime whether to include mime comments * @param bool $dates whether to include creation/update/check dates * * @return bool Whether it succeeded * * @access public */ function PMA_exportStructure($db, $table, $crlf, $error_url, $export_mode, $export_type, $do_relation = false, $do_comments = false, $do_mime = false, $dates = false) { $dump = ''; switch ($export_mode) { case 'create_table': $dump .= '<h2>' . __('Table structure for table') . ' ' . htmlspecialchars($table) . '</h2>'; $dump .= PMA_getTableDef($db, $table, $crlf, $error_url, $do_relation, $do_comments, $do_mime, $dates); break; case 'triggers': $dump = ''; $triggers = PMA_DBI_get_triggers($db, $table); if ($triggers) { $dump .= '<h2>' . __('Triggers') . ' ' . htmlspecialchars($table) . '</h2>'; $dump .= PMA_getTriggers($db, $table); } break; case 'create_view': $dump .= '<h2>' . __('Structure for view') . ' ' . htmlspecialchars($table) . '</h2>'; $dump .= PMA_getTableDef($db, $table, $crlf, $error_url, $do_relation, $do_comments, $do_mime, $dates, true, true); break; case 'stand_in': $dump .= '<h2>' . __('Stand-in structure for view') . ' ' . htmlspecialchars($table) . '</h2>'; // export a stand-in definition to resolve view dependencies $dump .= PMA_getTableDefStandIn($db, $table, $crlf); } // end switch return PMA_exportOutputHandler($dump); }
/** * Outputs table's structure * * @param string the database name * @param string the table name * @param string the end of line sequence * @param string the url to go back in case of error * @param boolean whether to include relation comments * @param boolean whether to include column comments * @param boolean whether to include mime comments * @param string 'stand_in', 'create_table', 'create_view' * @param string 'server', 'database', 'table' * * @return bool Whether it suceeded * * @access public */ function PMA_exportStructure($db, $table, $crlf, $error_url, $relation = FALSE, $comments = FALSE, $mime = FALSE, $dates = FALSE, $export_mode, $export_type) { $formatted_table_name = isset($GLOBALS['sql_backquotes']) ? PMA_backquote($table) : '\'' . $table . '\''; $dump = $crlf . $GLOBALS['comment_marker'] . '--------------------------------------------------------' . $crlf . $crlf . $GLOBALS['comment_marker'] . $crlf; switch ($export_mode) { case 'create_table': $dump .= $GLOBALS['comment_marker'] . $GLOBALS['strTableStructure'] . ' ' . $formatted_table_name . $crlf . $GLOBALS['comment_marker'] . $crlf; $dump .= PMA_getTableDef($db, $table, $crlf, $error_url, $dates) . ';' . $crlf; break; case 'create_view': $dump .= $GLOBALS['comment_marker'] . $GLOBALS['strStructureForView'] . ' ' . $formatted_table_name . $crlf . $GLOBALS['comment_marker'] . $crlf; // delete the stand-in table previously created (if any) if ($export_type != 'table') { $dump .= 'DROP TABLE IF EXISTS ' . PMA_backquote($table) . ';' . $crlf; } $dump .= PMA_getTableDef($db, $table, $crlf, $error_url, $dates) . ';' . $crlf; break; case 'stand_in': $dump .= $GLOBALS['comment_marker'] . $GLOBALS['strStandInStructureForView'] . ' ' . $formatted_table_name . $crlf . $GLOBALS['comment_marker'] . $crlf; // export a stand-in definition to resolve view dependencies $dump .= PMA_getTableDefStandIn($db, $table, $crlf); } // end switch $dump .= PMA_getTableComments($db, $table, $crlf, $relation, $comments, $mime); // this one is built by PMA_getTableDef() to use in table copy/move // but not in the case of export unset($GLOBALS['sql_constraints_query']); return PMA_exportOutputHandler($dump); }
/** * Outputs table's structure * * @param string $db database name * @param string $table table name * @param string $crlf the end of line sequence * @param string $error_url the url to go back in case of error * @param string $export_mode 'create_table', 'triggers', 'create_view', * 'stand_in' * @param string $export_type 'server', 'database', 'table' * @param bool $do_relation whether to include relation comments * @param bool $do_comments whether to include the pmadb-style column * comments as comments in the structure; * this is deprecated but the parameter is * left here because export.php calls * PMA_exportStructure() also for other * @param bool $do_mime whether to include mime comments * @param bool $dates whether to include creation/update/check dates * * @return bool Whether it succeeded * * @access public */ function PMA_exportStructure($db, $table, $crlf, $error_url, $export_mode, $export_type, $do_relation = false, $do_comments = false, $do_mime = false, $dates = false) { switch ($export_mode) { case 'create_table': $GLOBALS['odt_buffer'] .= '<text:h text:outline-level="2" text:style-name="Heading_2"' . ' text:is-list-header="true">' . __('Table structure for table') . ' ' . htmlspecialchars($table) . '</text:h>'; PMA_getTableDef($db, $table, $crlf, $error_url, $do_relation, $do_comments, $do_mime, $dates); break; case 'triggers': $triggers = PMA_DBI_get_triggers($db, $table); if ($triggers) { $GLOBALS['odt_buffer'] .= '<text:h text:outline-level="2" text:style-name="Heading_2"' . ' text:is-list-header="true">' . __('Triggers') . ' ' . htmlspecialchars($table) . '</text:h>'; PMA_getTriggers($db, $table); } break; case 'create_view': $GLOBALS['odt_buffer'] .= '<text:h text:outline-level="2" text:style-name="Heading_2"' . ' text:is-list-header="true">' . __('Structure for view') . ' ' . htmlspecialchars($table) . '</text:h>'; PMA_getTableDef($db, $table, $crlf, $error_url, $do_relation, $do_comments, $do_mime, $dates, true, true); break; case 'stand_in': $GLOBALS['odt_buffer'] .= '<text:h text:outline-level="2" text:style-name="Heading_2"' . ' text:is-list-header="true">' . __('Stand-in structure for view') . ' ' . htmlspecialchars($table) . '</text:h>'; // export a stand-in definition to resolve view dependencies PMA_getTableDefStandIn($db, $table, $crlf); } // end switch return true; }