/**
  * 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);
 }
Ejemplo n.º 2
0
Archivo: sql.php Proyecto: lifecom/test
/**
 * 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
 *
 * @return  bool     Whether it suceeded
 *
 * @access  public
 */
function PMA_exportStructure($db, $table, $crlf, $error_url, $relation = FALSE, $comments = FALSE, $mime = FALSE, $dates = FALSE)
{
    $formatted_table_name = isset($GLOBALS['use_backquotes']) ? PMA_backquote($table) : '\'' . $table . '\'';
    $dump = $crlf . $GLOBALS['comment_marker'] . '--------------------------------------------------------' . $crlf . $crlf . $GLOBALS['comment_marker'] . $crlf . $GLOBALS['comment_marker'] . $GLOBALS['strTableStructure'] . ' ' . $formatted_table_name . $crlf . $GLOBALS['comment_marker'] . $crlf . PMA_getTableDef($db, $table, $crlf, $error_url, $dates) . ';' . $crlf . PMA_getTableComments($db, $table, $crlf, $relation, $comments, $mime);
    return PMA_exportOutputHandler($dump);
}
Ejemplo n.º 3
0
 /**
  * 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);
 }
Ejemplo n.º 4
0
 /**
  * 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
  *
  * @return  bool     Whether it suceeded
  *
  * @access  public
  */
 function PMA_exportStructure($db, $table, $crlf, $error_url, $relation = FALSE, $comments = FALSE, $mime = FALSE, $dates = FALSE)
 {
     $formatted_table_name = isset($GLOBALS['sql_backquotes']) ? PMA_backquote($table) : '\'' . $table . '\'';
     $dump = $crlf . $GLOBALS['comment_marker'] . '--------------------------------------------------------' . $crlf . $crlf . $GLOBALS['comment_marker'] . $crlf . $GLOBALS['comment_marker'] . $GLOBALS['strTableStructure'] . ' ' . $formatted_table_name . $crlf . $GLOBALS['comment_marker'] . $crlf . PMA_getTableDef($db, $table, $crlf, $error_url, $dates) . ';' . $crlf . 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);
 }