home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / xampp-win32-1.6.7-installer.exe / phpMyAdmin / tbl_export.php < prev    next >
PHP Script  |  2008-06-23  |  3KB  |  93 lines

  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4.  *
  5.  * @version $Id: tbl_export.php 11061 2008-01-18 18:29:17Z lem9 $
  6.  */
  7.  
  8. /**
  9.  *
  10.  */
  11. require_once './libraries/common.inc.php';
  12.  
  13. /**
  14.  * Gets tables informations and displays top links
  15.  */
  16. require_once './libraries/tbl_common.php';
  17. $url_query .= '&goto=tbl_export.php&back=tbl_export.php';
  18. require_once './libraries/tbl_info.inc.php';
  19.  
  20. // Dump of a table
  21.  
  22. $export_page_title = $strViewDump;
  23.  
  24. // When we have some query, we need to remove LIMIT from that and possibly
  25. // generate WHERE clause (if we are asked to export specific rows)
  26.  
  27. if (! empty($sql_query)) {
  28.     // Parse query so we can work with tokens
  29.     $parsed_sql = PMA_SQP_parse($sql_query);
  30.     $analyzed_sql = PMA_SQP_analyze($parsed_sql);
  31.  
  32.     // Need to generate WHERE clause?
  33.     if (isset($primary_key)) {
  34.         // Yes => rebuild query from scracts, this doesn't work with nested
  35.         // selects :-(
  36.         $sql_query = 'SELECT ';
  37.  
  38.         if (isset($analyzed_sql[0]['queryflags']['distinct'])) {
  39.             $sql_query .= ' DISTINCT ';
  40.         }
  41.  
  42.         $sql_query .= $analyzed_sql[0]['select_expr_clause'];
  43.  
  44.         if (!empty($analyzed_sql[0]['from_clause'])) {
  45.             $sql_query .= ' FROM ' . $analyzed_sql[0]['from_clause'];
  46.         }
  47.  
  48.         $wheres = array();
  49.  
  50.         if (isset($primary_key) && is_array($primary_key)
  51.          && count($primary_key) > 0) {
  52.             $wheres[] = '(' . implode(') OR (',$primary_key) . ')';
  53.         }
  54.  
  55.         if (!empty($analyzed_sql[0]['where_clause']))  {
  56.             $wheres[] = $analyzed_sql[0]['where_clause'];
  57.         }
  58.  
  59.         if (count($wheres) > 0) {
  60.             $sql_query .= ' WHERE (' . implode(') AND (', $wheres) . ')';
  61.         }
  62.  
  63.         if (!empty($analyzed_sql[0]['group_by_clause'])) {
  64.             $sql_query .= ' GROUP BY ' . $analyzed_sql[0]['group_by_clause'];
  65.         }
  66.         if (!empty($analyzed_sql[0]['having_clause'])) {
  67.             $sql_query .= ' HAVING ' . $analyzed_sql[0]['having_clause'];
  68.         }
  69.         if (!empty($analyzed_sql[0]['order_by_clause'])) {
  70.             $sql_query .= ' ORDER BY ' . $analyzed_sql[0]['order_by_clause'];
  71.         }
  72.     } else {
  73.         // Just crop LIMIT clause
  74.         $sql_query = $analyzed_sql[0]['section_before_limit'] . $analyzed_sql[0]['section_after_limit'];
  75.     }
  76.     $message = $GLOBALS['strSuccess'];
  77. }
  78.  
  79. /**
  80.  * Displays top menu links
  81.  */
  82. require './libraries/tbl_links.inc.php';
  83.  
  84. $export_type = 'table';
  85. require_once './libraries/display_export.lib.php';
  86.  
  87.  
  88. /**
  89.  * Displays the footer
  90.  */
  91. require_once './libraries/footer.inc.php';
  92. ?>
  93.