[ Index ] |
|
Code source de phpMyAdmin 2.10.3 |
1 <?php 2 /* $Id: tbl_export.php 10144 2007-03-20 11:22:31Z cybot_tm $ */ 3 // vim: expandtab sw=4 ts=4 sts=4: 4 5 require_once ('./libraries/common.lib.php'); 6 7 /** 8 * Gets tables informations and displays top links 9 */ 10 require_once ('./libraries/tbl_common.php'); 11 $url_query .= '&goto=tbl_export.php&back=tbl_export.php'; 12 require_once ('./libraries/tbl_info.inc.php'); 13 14 // Dump of a table 15 16 $export_page_title = $strViewDump; 17 18 // When we have some query, we need to remove LIMIT from that and possibly 19 // generate WHERE clause (if we are asked to export specific rows) 20 21 if (isset($sql_query)) { 22 // Parse query so we can work with tokens 23 $parsed_sql = PMA_SQP_parse($sql_query); 24 25 // Need to generate WHERE clause? 26 if (isset($primary_key)) { 27 // Yes => rebuild query from scracts, this doesn't work with nested 28 // selects :-( 29 $analyzed_sql = PMA_SQP_analyze($parsed_sql); 30 $sql_query = 'SELECT '; 31 32 if (isset($analyzed_sql[0]['queryflags']['distinct'])) { 33 $sql_query .= ' DISTINCT '; 34 } 35 36 $sql_query .= $analyzed_sql[0]['select_expr_clause']; 37 38 if (!empty($analyzed_sql[0]['from_clause'])) { 39 $sql_query .= ' FROM ' . $analyzed_sql[0]['from_clause']; 40 } 41 42 $wheres = array(); 43 44 if (isset($primary_key) && is_array($primary_key) 45 && count($primary_key) > 0) { 46 $wheres[] = '(' . implode(') OR (',$primary_key) . ')'; 47 } 48 49 if (!empty($analyzed_sql[0]['where_clause'])) { 50 $wheres[] = $analyzed_sql[0]['where_clause']; 51 } 52 53 if (count($wheres) > 0 ) { 54 $sql_query .= ' WHERE (' . implode(') AND (', $wheres) . ')'; 55 } 56 57 if (!empty($analyzed_sql[0]['group_by_clause'])) { 58 $sql_query .= ' GROUP BY ' . $analyzed_sql[0]['group_by_clause']; 59 } 60 if (!empty($analyzed_sql[0]['having_clause'])) { 61 $sql_query .= ' HAVING ' . $analyzed_sql[0]['having_clause']; 62 } 63 if (!empty($analyzed_sql[0]['order_by_clause'])) { 64 $sql_query .= ' ORDER BY ' . $analyzed_sql[0]['order_by_clause']; 65 } 66 } else { 67 // Just crop LIMIT clause 68 $inside_bracket = FALSE; 69 for ($i = $parsed_sql['len'] - 1; $i >= 0; $i--) { 70 if ($parsed_sql[$i]['type'] == 'punct_bracket_close_round') { 71 $inside_bracket = TRUE; 72 continue; 73 } 74 if ($parsed_sql[$i]['type'] == 'punct_bracket_open_round') { 75 $inside_bracket = FALSE; 76 continue; 77 } 78 if (!$inside_bracket && $parsed_sql[$i]['type'] == 'alpha_reservedWord' && strtoupper($parsed_sql[$i]['data']) == 'LIMIT') { 79 // We found LIMIT to remove 80 81 $sql_query = ''; 82 83 // Concatenate parts before 84 for ($j = 0; $j < $i; $j++) { 85 $sql_query .= $parsed_sql[$j]['data'] . ' '; 86 } 87 88 // Skip LIMIT 89 $i++; 90 while ($i < $parsed_sql['len'] && 91 ($parsed_sql[$i]['type'] != 'alpha_reservedWord' || 92 ($parsed_sql[$i]['type'] == 'alpha_reservedWord' && $parsed_sql[$i]['data'] == 'OFFSET'))) { 93 $i++; 94 } 95 96 // Add remaining parts 97 while ($i < $parsed_sql['len']) { 98 $sql_query .= $parsed_sql[$i]['data'] . ' '; 99 $i++; 100 } 101 break; 102 } 103 } 104 } 105 $message = $GLOBALS['strSuccess']; 106 } 107 108 /** 109 * Displays top menu links 110 */ 111 require ('./libraries/tbl_links.inc.php'); 112 113 $export_type = 'table'; 114 require_once ('./libraries/display_export.lib.php'); 115 116 117 /** 118 * Displays the footer 119 */ 120 require_once ('./libraries/footer.inc.php'); 121 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 15:18:20 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |