Translated using Weblate.
[phpmyadmin.git] / tbl_export.php
blob6dfd6960eabdff40965741ebdab5fab7516edf83
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 $GLOBALS['js_include'][] = 'export.js';
14 $GLOBALS['js_include'][] = 'codemirror/lib/codemirror.js';
15 $GLOBALS['js_include'][] = 'codemirror/mode/mysql/mysql.js';
17 /**
18 * Gets tables informations and displays top links
20 require_once './libraries/tbl_common.php';
21 $url_query .= '&amp;goto=tbl_export.php&amp;back=tbl_export.php';
22 require_once './libraries/tbl_info.inc.php';
24 // Dump of a table
26 $export_page_title = __('View dump (schema) of table');
28 // When we have some query, we need to remove LIMIT from that and possibly
29 // generate WHERE clause (if we are asked to export specific rows)
31 if (! empty($sql_query)) {
32 // Parse query so we can work with tokens
33 $parsed_sql = PMA_SQP_parse($sql_query);
34 $analyzed_sql = PMA_SQP_analyze($parsed_sql);
36 // Need to generate WHERE clause?
37 if (isset($where_clause)) {
38 // Yes => rebuild query from scratch; this doesn't work with nested
39 // selects :-(
40 $sql_query = 'SELECT ';
42 if (isset($analyzed_sql[0]['queryflags']['distinct'])) {
43 $sql_query .= ' DISTINCT ';
46 $sql_query .= $analyzed_sql[0]['select_expr_clause'];
48 if (!empty($analyzed_sql[0]['from_clause'])) {
49 $sql_query .= ' FROM ' . $analyzed_sql[0]['from_clause'];
52 $wheres = array();
54 if (isset($where_clause) && is_array($where_clause)
55 && count($where_clause) > 0) {
56 $wheres[] = '(' . implode(') OR (', $where_clause) . ')';
59 if (!empty($analyzed_sql[0]['where_clause'])) {
60 $wheres[] = $analyzed_sql[0]['where_clause'];
63 if (count($wheres) > 0) {
64 $sql_query .= ' WHERE (' . implode(') AND (', $wheres) . ')';
67 if (!empty($analyzed_sql[0]['group_by_clause'])) {
68 $sql_query .= ' GROUP BY ' . $analyzed_sql[0]['group_by_clause'];
70 if (!empty($analyzed_sql[0]['having_clause'])) {
71 $sql_query .= ' HAVING ' . $analyzed_sql[0]['having_clause'];
73 if (!empty($analyzed_sql[0]['order_by_clause'])) {
74 $sql_query .= ' ORDER BY ' . $analyzed_sql[0]['order_by_clause'];
76 } else {
77 // Just crop LIMIT clause
78 $sql_query = $analyzed_sql[0]['section_before_limit'] . $analyzed_sql[0]['section_after_limit'];
80 $message = PMA_Message::success();
83 /**
84 * Displays top menu links
86 require './libraries/tbl_links.inc.php';
88 $export_type = 'table';
89 require_once './libraries/display_export.lib.php';
92 /**
93 * Displays the footer
95 require './libraries/footer.inc.php';