2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Ensure the database and the table exist (else move to the "parent" script)
9 declare(strict_types
=1);
12 use PhpMyAdmin\Message
;
13 use PhpMyAdmin\Response
;
16 if (! defined('PHPMYADMIN')) {
23 if (strlen($db) > 0) {
24 $is_db = @$GLOBALS['dbi']->selectDb($db);
30 // not a valid db name -> back to the welcome page
31 if (! defined('IS_TRANSFORMATION_WRAPPER')) {
32 $response = Response
::getInstance();
33 if ($response->isAjax()) {
34 $response->setRequestStatus(false);
37 Message
::error(__('No databases selected.'))
40 $url_params = ['reload' => 1];
41 if (isset($message)) {
42 $url_params['message'] = $message;
44 if (! empty($sql_query)) {
45 $url_params['sql_query'] = $sql_query;
47 if (isset($show_as_php)) {
48 $url_params['show_as_php'] = $show_as_php;
50 Core
::sendHeaderLocation(
52 . Url
::getCommonRaw($url_params)
58 } // end if (ensures db exists)
61 && ! defined('PMA_SUBMIT_MULT')
62 && ! defined('TABLE_MAY_BE_ABSENT')
64 // Not a valid table name -> back to the db_sql.php
66 if (strlen($table) > 0) {
67 $is_table = $GLOBALS['dbi']->getCachedTableContent([$db, $table], false);
70 $_result = $GLOBALS['dbi']->tryQuery(
72 . $GLOBALS['dbi']->escapeString($table) . '\';',
73 PhpMyAdmin\DatabaseInterface
::CONNECT_USER
,
74 PhpMyAdmin\DatabaseInterface
::QUERY_STORE
76 $is_table = @$GLOBALS['dbi']->numRows($_result);
77 $GLOBALS['dbi']->freeResult($_result);
84 if (! defined('IS_TRANSFORMATION_WRAPPER')) {
85 if (strlen($table) > 0) {
86 // SHOW TABLES doesn't show temporary tables, so try select
87 // (as it can happen just in case temporary table, it should be
91 * @todo should this check really
92 * only happen if IS_TRANSFORMATION_WRAPPER?
94 $_result = $GLOBALS['dbi']->tryQuery(
95 'SELECT COUNT(*) FROM ' . PhpMyAdmin\Util
::backquote($table)
97 PhpMyAdmin\DatabaseInterface
::CONNECT_USER
,
98 PhpMyAdmin\DatabaseInterface
::QUERY_STORE
100 $is_table = ($_result && @$GLOBALS['dbi']->numRows($_result));
101 $GLOBALS['dbi']->freeResult($_result);
105 include ROOT_PATH
. 'db_sql.php';
114 } // end if (ensures table exists)