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