sanitize $after_field
[phpmyadmin/dkf.git] / tbl_export.php
blobb648693d77bb578fb1211c36d8773d00b26c011d
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
5 * @version $Id$
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 = $strViewDump;
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($primary_key)) {
34 // Yes => rebuild query from scracts, 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($primary_key) && is_array($primary_key)
51 && count($primary_key) > 0) {
52 $wheres[] = '(' . implode(') OR (',$primary_key) . ')';
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 = $GLOBALS['strSuccess'];
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_once './libraries/footer.inc.php';