code and comments cleanup
[phpmyadmin/crack.git] / tbl_export.php
blob959a95dc90c57f6c88dbbe2e753c720ea7c0d224
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
5 * @package phpMyAdmin
6 */
8 /**
11 require_once './libraries/common.inc.php';
13 /**
14 * Gets tables informations and displays top links
16 require_once './libraries/tbl_common.php';
17 $url_query .= '&amp;goto=tbl_export.php&amp;back=tbl_export.php';
18 require_once './libraries/tbl_info.inc.php';
20 // Dump of a table
22 $export_page_title = __('View dump (schema) of table');
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)
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);
32 // Need to generate WHERE clause?
33 if (isset($where_clause)) {
34 // Yes => rebuild query from scratch; this doesn't work with nested
35 // selects :-(
36 $sql_query = 'SELECT ';
38 if (isset($analyzed_sql[0]['queryflags']['distinct'])) {
39 $sql_query .= ' DISTINCT ';
42 $sql_query .= $analyzed_sql[0]['select_expr_clause'];
44 if (!empty($analyzed_sql[0]['from_clause'])) {
45 $sql_query .= ' FROM ' . $analyzed_sql[0]['from_clause'];
48 $wheres = array();
50 if (isset($where_clause) && is_array($where_clause)
51 && count($where_clause) > 0) {
52 $wheres[] = '(' . implode(') OR (',$where_clause) . ')';
55 if (!empty($analyzed_sql[0]['where_clause'])) {
56 $wheres[] = $analyzed_sql[0]['where_clause'];
59 if (count($wheres) > 0) {
60 $sql_query .= ' WHERE (' . implode(') AND (', $wheres) . ')';
63 if (!empty($analyzed_sql[0]['group_by_clause'])) {
64 $sql_query .= ' GROUP BY ' . $analyzed_sql[0]['group_by_clause'];
66 if (!empty($analyzed_sql[0]['having_clause'])) {
67 $sql_query .= ' HAVING ' . $analyzed_sql[0]['having_clause'];
69 if (!empty($analyzed_sql[0]['order_by_clause'])) {
70 $sql_query .= ' ORDER BY ' . $analyzed_sql[0]['order_by_clause'];
72 } else {
73 // Just crop LIMIT clause
74 $sql_query = $analyzed_sql[0]['section_before_limit'] . $analyzed_sql[0]['section_after_limit'];
76 $message = PMA_Message::success();
79 /**
80 * Displays top menu links
82 require './libraries/tbl_links.inc.php';
84 $export_type = 'table';
85 require_once './libraries/display_export.lib.php';
88 /**
89 * Displays the footer
91 require './libraries/footer.inc.php';