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 use PMA\libraries\Message
;
10 use PMA\libraries\Response
;
11 use PMA\libraries\URL
;
13 if (! defined('PHPMYADMIN')) {
18 if (strlen($db) > 0) {
19 $is_db = @$GLOBALS['dbi']->selectDb($db);
25 // not a valid db name -> back to the welcome page
26 if (! defined('IS_TRANSFORMATION_WRAPPER')) {
27 $response = Response
::getInstance();
28 if ($response->isAjax()) {
29 $response->setRequestStatus(false);
32 Message
::error(__('No databases selected.'))
35 $url_params = array('reload' => 1);
36 if (isset($message)) {
37 $url_params['message'] = $message;
39 if (! empty($sql_query)) {
40 $url_params['sql_query'] = $sql_query;
42 if (isset($show_as_php)) {
43 $url_params['show_as_php'] = $show_as_php;
45 PMA_sendHeaderLocation(
47 . URL
::getCommonRaw($url_params)
53 } // end if (ensures db exists)
56 && !defined('PMA_SUBMIT_MULT')
57 && !defined('TABLE_MAY_BE_ABSENT')
59 // Not a valid table name -> back to the db_sql.php
61 if (strlen($table) > 0) {
62 $is_table = $GLOBALS['dbi']->getCachedTableContent(array($db, $table), false);
65 $_result = $GLOBALS['dbi']->tryQuery(
67 . $GLOBALS['dbi']->escapeString($table) . '\';',
68 null, PMA\libraries\DatabaseInterface
::QUERY_STORE
70 $is_table = @$GLOBALS['dbi']->numRows($_result);
71 $GLOBALS['dbi']->freeResult($_result);
78 if (!defined('IS_TRANSFORMATION_WRAPPER')) {
79 if (strlen($table) > 0) {
80 // SHOW TABLES doesn't show temporary tables, so try select
81 // (as it can happen just in case temporary table, it should be
85 * @todo should this check really
86 * only happen if IS_TRANSFORMATION_WRAPPER?
88 $_result = $GLOBALS['dbi']->tryQuery(
89 'SELECT COUNT(*) FROM ' . PMA\libraries\Util
::backquote($table)
92 PMA\libraries\DatabaseInterface
::QUERY_STORE
94 $is_table = ($_result && @$GLOBALS['dbi']->numRows($_result));
95 $GLOBALS['dbi']->freeResult($_result);
99 include './db_sql.php';
108 } // end if (ensures table exists)