2 /* vim: set expandtab sw=4 ts=4 sts=4: */
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);
51 * Gets tables information and displays top links
53 require_once ROOT_PATH
. 'libraries/tbl_common.inc.php';
54 $url_query .= '&goto=tbl_export.php&back=tbl_export.php';
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
)
69 // Checking if the WHERE clause has to be replaced.
70 if (! empty($where_clause) && is_array($where_clause)) {
73 'WHERE (' . implode(') OR (', $where_clause) . ')',
77 // Preparing to remove the LIMIT clause.
83 // Replacing the clauses.
84 $sql_query = PhpMyAdmin\SqlParser\Utils\Query
::replaceClauses(
85 $parser->statements
[0],
91 echo PhpMyAdmin\Util
::getMessage(PhpMyAdmin\Message
::success());
94 if (! isset($sql_query)) {
97 if (! isset($num_tables)) {
100 if (! isset($unlim_num_rows)) {
103 if (! isset($multi_values)) {
106 $response = Response
::getInstance();
108 $displayExport->getDisplay(