Translation update done using Pootle.
[phpmyadmin/ammaryasirr.git] / tbl_export.php
blob6a7d03ff05777d94a572a125802067c6e697aa1c
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 /**
16 * Gets tables informations and displays top links
18 require_once './libraries/tbl_common.php';
19 $url_query .= '&amp;goto=tbl_export.php&amp;back=tbl_export.php';
20 require_once './libraries/tbl_info.inc.php';
22 // Dump of a table
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
37 // selects :-(
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'];
50 $wheres = array();
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'];
74 } else {
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();
81 /**
82 * Displays top menu links
84 require './libraries/tbl_links.inc.php';
86 $export_type = 'table';
87 require_once './libraries/display_export.lib.php';
90 /**
91 * Displays the footer
93 require './libraries/footer.inc.php';