Fix left frame reloading after dropping table (bug #1034531).
[phpmyadmin/crack.git] / tbl_properties_export.php
blob6b3357a54aa8bd5d014ca384c0c7225bb4b39aae
1 <?php
2 /* $Id$ */
3 // vim: expandtab sw=4 ts=4 sts=4:
6 /**
7 * Gets tables informations and displays top links
8 */
9 require('./tbl_properties_common.php');
10 $url_query .= '&amp;goto=tbl_properties_export.php&amp;back=tbl_properties_export.php';
11 require('./tbl_properties_table_info.php');
14 <!-- Dump of a table -->
15 <?php
16 $export_page_title = $strViewDump;
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)
21 if (isset($sql_query)) {
22 // Parse query so we can work with tokens
23 $parsed_sql = PMA_SQP_parse($sql_query);
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 ';
32 if (isset($analyzed_sql[0]['queryflags']['distinct'])) {
33 $sql_query .= ' DISTINCT ';
36 $sql_query .= $analyzed_sql[0]['select_expr_clause'];
38 if (!empty($analyzed_sql[0]['from_clause'])) {
39 $sql_query .= ' FROM ' . $analyzed_sql[0]['from_clause'];
41 if (isset($primary_key)) {
42 $sql_query .= ' WHERE ';
43 $conj = '';
44 foreach ($primary_key AS $i => $key) {
45 $sql_query .= $conj . '( ' . $key . ' ) ';
46 $conj = 'OR ';
48 } elseif (!empty($analyzed_sql[0]['where_clause'])) {
49 $sql_query .= ' WHERE ' . $analyzed_sql[0]['where_clause'];
51 if (!empty($analyzed_sql[0]['group_by_clause'])) {
52 $sql_query .= ' GROUP BY ' . $analyzed_sql[0]['group_by_clause'];
54 if (!empty($analyzed_sql[0]['having_clause'])) {
55 $sql_query .= ' HAVING ' . $analyzed_sql[0]['having_clause'];
57 if (!empty($analyzed_sql[0]['order_by_clause'])) {
58 $sql_query .= ' ORDER BY ' . $analyzed_sql[0]['order_by_clause'];
60 } else {
61 // Just crop LIMIT clause
62 $inside_bracket = FALSE;
63 for ($i = $parsed_sql['len'] - 1; $i >= 0; $i--) {
64 if ($parsed_sql[$i]['type'] == 'punct_bracket_close_round') {
65 $inside_bracket = TRUE;
66 continue;
68 if ($parsed_sql[$i]['type'] == 'punct_bracket_open_round') {
69 $inside_bracket = FALSE;
70 continue;
72 if (!$inside_bracket && $parsed_sql[$i]['type'] == 'alpha_reservedWord' && $parsed_sql[$i]['data'] == 'LIMIT') {
73 // We found LIMIT to remove
75 $sql_query = '';
77 // Concatenate parts before
78 for ($j = 0; $j < $i; $j++) {
79 $sql_query .= $parsed_sql[$j]['data'] . ' ';
82 // Skip LIMIT
83 $i++;
84 while ($i < $parsed_sql['len'] &&
85 ($parsed_sql[$i]['type'] != 'alpha_reservedWord' ||
86 ($parsed_sql[$i]['type'] == 'alpha_reservedWord' && $parsed_sql[$i]['data'] == 'OFFSET'))) {
87 $i++;
90 // Add remaining parts
91 while ($i < $parsed_sql['len']) {
92 $sql_query .= $parsed_sql[$i]['data'] . ' ';
93 $i++;
95 break;
99 // TODO: can we avoid reparsing the query here?
100 PMA_showMessage($GLOBALS['strSQLQuery']);
103 $export_type = 'table';
104 require_once('./libraries/display_export.lib.php');
108 * Displays the footer
110 require_once('./footer.inc.php');