2 /* vim: set expandtab sw=4 ts=4 sts=4: */
11 require_once './libraries/common.inc.php';
13 $GLOBALS['js_include'][] = 'export.js';
16 * Gets tables informations and displays top links
18 require_once './libraries/tbl_common.php';
19 $url_query .= '&goto=tbl_export.php&back=tbl_export.php';
20 require_once './libraries/tbl_info.inc.php';
24 $export_page_title = __('View dump (schema) of table');
26 // When we have some query, we need to remove LIMIT from that and possibly
27 // generate WHERE clause (if we are asked to export specific rows)
29 if (! empty($sql_query)) {
30 // Parse query so we can work with tokens
31 $parsed_sql = PMA_SQP_parse($sql_query);
32 $analyzed_sql = PMA_SQP_analyze($parsed_sql);
34 // Need to generate WHERE clause?
35 if (isset($where_clause)) {
36 // Yes => rebuild query from scratch; this doesn't work with nested
38 $sql_query = 'SELECT ';
40 if (isset($analyzed_sql[0]['queryflags']['distinct'])) {
41 $sql_query .= ' DISTINCT ';
44 $sql_query .= $analyzed_sql[0]['select_expr_clause'];
46 if (!empty($analyzed_sql[0]['from_clause'])) {
47 $sql_query .= ' FROM ' . $analyzed_sql[0]['from_clause'];
52 if (isset($where_clause) && is_array($where_clause)
53 && count($where_clause) > 0) {
54 $wheres[] = '(' . implode(') OR (',$where_clause) . ')';
57 if (!empty($analyzed_sql[0]['where_clause'])) {
58 $wheres[] = $analyzed_sql[0]['where_clause'];
61 if (count($wheres) > 0) {
62 $sql_query .= ' WHERE (' . implode(') AND (', $wheres) . ')';
65 if (!empty($analyzed_sql[0]['group_by_clause'])) {
66 $sql_query .= ' GROUP BY ' . $analyzed_sql[0]['group_by_clause'];
68 if (!empty($analyzed_sql[0]['having_clause'])) {
69 $sql_query .= ' HAVING ' . $analyzed_sql[0]['having_clause'];
71 if (!empty($analyzed_sql[0]['order_by_clause'])) {
72 $sql_query .= ' ORDER BY ' . $analyzed_sql[0]['order_by_clause'];
75 // Just crop LIMIT clause
76 $sql_query = $analyzed_sql[0]['section_before_limit'] . $analyzed_sql[0]['section_after_limit'];
78 $message = PMA_Message
::success();
82 * Displays top menu links
84 require './libraries/tbl_links.inc.php';
86 $export_type = 'table';
87 require_once './libraries/display_export.lib.php';
93 require './libraries/footer.inc.php';