Translated using Weblate (Slovenian)
[phpmyadmin.git] / tbl_export.php
blob3269f63d85c80773ebd048df4df2b81090366c7a
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Table export
6 * @package PhpMyAdmin
7 */
8 declare(strict_types=1);
10 use PhpMyAdmin\Config\PageSettings;
11 use PhpMyAdmin\DatabaseInterface;
12 use PhpMyAdmin\Display\Export;
13 use PhpMyAdmin\Relation;
14 use PhpMyAdmin\Response;
16 if (! defined('ROOT_PATH')) {
17 define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
20 global $containerBuilder, $db, $table, $url_query;
22 require_once ROOT_PATH . 'libraries/common.inc.php';
24 /** @var Response $response */
25 $response = $containerBuilder->get(Response::class);
27 /** @var DatabaseInterface $dbi */
28 $dbi = $containerBuilder->get(DatabaseInterface::class);
30 PageSettings::showGroup('Export');
32 $header = $response->getHeader();
33 $scripts = $header->getScripts();
34 $scripts->addFile('export.js');
36 // Get the relation settings
37 /** @var Relation $relation */
38 $relation = $containerBuilder->get('relation');
39 $cfgRelation = $relation->getRelationsParam();
41 /** @var Export $displayExport */
42 $displayExport = $containerBuilder->get('display_export');
44 // handling export template actions
45 if (isset($_POST['templateAction']) && $cfgRelation['exporttemplateswork']) {
46 $displayExport->handleTemplateActions($cfgRelation);
47 exit;
50 /**
51 * Gets tables information and displays top links
53 require_once ROOT_PATH . 'libraries/tbl_common.inc.php';
54 $url_query .= '&amp;goto=tbl_export.php&amp;back=tbl_export.php';
56 // Dump of a table
58 $export_page_title = __('View dump (schema) of table');
60 // When we have some query, we need to remove LIMIT from that and possibly
61 // generate WHERE clause (if we are asked to export specific rows)
63 if (! empty($sql_query)) {
64 $parser = new PhpMyAdmin\SqlParser\Parser($sql_query);
66 if (! empty($parser->statements[0])
67 && ($parser->statements[0] instanceof PhpMyAdmin\SqlParser\Statements\SelectStatement)
68 ) {
69 // Checking if the WHERE clause has to be replaced.
70 if (! empty($where_clause) && is_array($where_clause)) {
71 $replaces[] = [
72 'WHERE',
73 'WHERE (' . implode(') OR (', $where_clause) . ')',
77 // Preparing to remove the LIMIT clause.
78 $replaces[] = [
79 'LIMIT',
80 '',
83 // Replacing the clauses.
84 $sql_query = PhpMyAdmin\SqlParser\Utils\Query::replaceClauses(
85 $parser->statements[0],
86 $parser->list,
87 $replaces
91 echo PhpMyAdmin\Util::getMessage(PhpMyAdmin\Message::success());
94 if (! isset($sql_query)) {
95 $sql_query = '';
97 if (! isset($num_tables)) {
98 $num_tables = 0;
100 if (! isset($unlim_num_rows)) {
101 $unlim_num_rows = 0;
103 if (! isset($multi_values)) {
104 $multi_values = '';
106 $response = Response::getInstance();
107 $response->addHTML(
108 $displayExport->getDisplay(
109 'table',
110 $db,
111 $table,
112 $sql_query,
113 $num_tables,
114 $unlim_num_rows,
115 $multi_values