2 /* vim: set expandtab sw=4 ts=4 sts=4: */
8 declare(strict_types
=1);
10 use PhpMyAdmin\DatabaseInterface
;
11 use PhpMyAdmin\Message
;
12 use PhpMyAdmin\Operations
;
13 use PhpMyAdmin\Relation
;
14 use PhpMyAdmin\Response
;
16 use PhpMyAdmin\Template
;
19 if (! defined('ROOT_PATH')) {
20 define('ROOT_PATH', __DIR__
. DIRECTORY_SEPARATOR
);
23 global $sql_query, $url_query;
25 require_once ROOT_PATH
. 'libraries/common.inc.php';
27 /** @var Response $response */
28 $response = $containerBuilder->get(Response
::class);
30 /** @var DatabaseInterface $dbi */
31 $dbi = $containerBuilder->get(DatabaseInterface
::class);
33 $pma_table = new Table($GLOBALS['table'], $GLOBALS['db']);
35 $header = $response->getHeader();
36 $scripts = $header->getScripts();
37 $scripts->addFile('table/operations.js');
39 /** @var Template $template */
40 $template = $containerBuilder->get('template');
45 require ROOT_PATH
. 'libraries/tbl_common.inc.php';
46 $url_query .= '&goto=view_operations.php&back=view_operations.php';
47 $url_params['goto'] = $url_params['back'] = 'view_operations.php';
49 /** @var Relation $relation */
50 $relation = $containerBuilder->get('relation');
51 $operations = new Operations($dbi, $relation);
56 $_message = new Message();
58 if (isset($_POST['submitoptions'])) {
59 if (isset($_POST['new_name'])) {
60 if ($pma_table->rename($_POST['new_name'])) {
61 $_message->addText($pma_table->getLastMessage());
63 $GLOBALS['table'] = $pma_table->getName();
64 /* Force reread after rename */
65 $pma_table->getStatusInfo(null, true);
68 $_message->addText($pma_table->getLastError());
73 $warning_messages = $operations->getWarningMessagesArray();
77 // set to success by default, because result set could be empty
78 // (for example, a table rename)
79 if (empty($_message->getString())) {
82 __('Your SQL query has been executed successfully.')
85 $_message->addText(__('Error'));
87 // $result should exist, regardless of $_message
88 $_type = $result ?
'success' : 'error';
90 if (! empty($warning_messages)) {
91 $_message->addMessagesString($warning_messages);
92 $_message->isError(true);
93 unset($warning_messages);
95 echo Util
::getMessage(
101 unset($_message, $_type);
103 $url_params['goto'] = 'view_operations.php';
104 $url_params['back'] = 'view_operations.php';
106 $drop_view_url_params = array_merge(
109 'sql_query' => 'DROP VIEW ' . Util
::backquote($GLOBALS['table']),
110 'goto' => 'tbl_structure.php',
113 'message_to_show' => sprintf(
114 __('View %s has been dropped.'),
117 'table' => $GLOBALS['table'],
121 echo $template->render('table/operations/view', [
122 'db' => $GLOBALS['db'],
123 'table' => $GLOBALS['table'],
124 'delete_data_or_table_link' => $operations->getDeleteDataOrTablelink(
125 $drop_view_url_params,
127 __('Delete the view (DROP)'),