Translated using Weblate (Spanish)
[phpmyadmin.git] / tbl_export.php
blob557dcb352b1a0917747c4469badb837f22b46a1c
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 $response = PMA_Response::getInstance();
14 $header = $response->getHeader();
15 $scripts = $header->getScripts();
16 $scripts->addFile('export.js');
18 /**
19 * Gets tables informations and displays top links
21 require_once 'libraries/tbl_common.inc.php';
22 $url_query .= '&amp;goto=tbl_export.php&amp;back=tbl_export.php';
23 require_once 'libraries/tbl_info.inc.php';
25 // Dump of a table
27 $export_page_title = __('View dump (schema) of table');
29 // When we have some query, we need to remove LIMIT from that and possibly
30 // generate WHERE clause (if we are asked to export specific rows)
32 if (! empty($sql_query)) {
33 // Parse query so we can work with tokens
34 $parsed_sql = PMA_SQP_parse($sql_query);
35 $analyzed_sql = PMA_SQP_analyze($parsed_sql);
37 // Need to generate WHERE clause?
38 if (isset($where_clause)) {
40 $temp_sql_array = preg_split("/\bwhere\b/i", $sql_query);
42 // The part "SELECT `id`, `name` FROM `customers`"
43 // is not modified by the next code segment, when exporting
44 // the result set from a query such as
45 // "SELECT `id`, `name` FROM `customers` WHERE id NOT IN
46 // ( SELECT id FROM companies WHERE name LIKE '%u%')"
47 $sql_query = $temp_sql_array[0];
49 // Append the where clause using the primary key of each row
50 if (is_array($where_clause) && (count($where_clause) > 0)) {
51 $sql_query .= ' WHERE (' . implode(') OR (', $where_clause) . ')';
54 if (!empty($analyzed_sql[0]['group_by_clause'])) {
55 $sql_query .= ' GROUP BY ' . $analyzed_sql[0]['group_by_clause'];
57 if (!empty($analyzed_sql[0]['having_clause'])) {
58 $sql_query .= ' HAVING ' . $analyzed_sql[0]['having_clause'];
60 if (!empty($analyzed_sql[0]['order_by_clause'])) {
61 $sql_query .= ' ORDER BY ' . $analyzed_sql[0]['order_by_clause'];
63 } else {
64 // Just crop LIMIT clause
65 $sql_query = $analyzed_sql[0]['section_before_limit'] . $analyzed_sql[0]['section_after_limit'];
67 echo PMA_Util::getMessage(PMA_Message::success());
70 $export_type = 'table';
71 require_once 'libraries/display_export.lib.php';