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 if (! defined('PHPMYADMIN')) {
13 /** @var PMA_String $pmaString */
14 $pmaString = $GLOBALS['PMA_String'];
16 if (/*overload*/mb_strlen($db)) {
17 $is_db = @$GLOBALS['dbi']->selectDb($db);
23 // not a valid db name -> back to the welcome page
24 if (! defined('IS_TRANSFORMATION_WRAPPER')) {
25 $response = PMA_Response
::getInstance();
26 if ($response->isAjax()) {
27 $response->isSuccess(false);
30 PMA_Message
::error(__('No databases selected.'))
33 $url_params = array('reload' => 1);
34 if (isset($message)) {
35 $url_params['message'] = $message;
37 if (! empty($sql_query)) {
38 $url_params['sql_query'] = $sql_query;
40 if (isset($show_as_php)) {
41 $url_params['show_as_php'] = $show_as_php;
43 PMA_sendHeaderLocation(
44 $cfg['PmaAbsoluteUri'] . 'index.php'
45 . PMA_URL_getCommon($url_params, 'text')
51 } // end if (ensures db exists)
54 && !defined('PMA_SUBMIT_MULT')
55 && !defined('TABLE_MAY_BE_ABSENT')
57 // Not a valid table name -> back to the db_sql.php
59 if (/*overload*/mb_strlen($table)) {
60 $is_table = $GLOBALS['dbi']->getCachedTableContent("${db}.${table}", false);
63 $_result = $GLOBALS['dbi']->tryQuery(
64 'SHOW TABLES LIKE \'' . PMA_Util
::sqlAddSlashes($table, true)
66 null, PMA_DatabaseInterface
::QUERY_STORE
68 $is_table = @$GLOBALS['dbi']->numRows($_result);
69 $GLOBALS['dbi']->freeResult($_result);
76 if (!defined('IS_TRANSFORMATION_WRAPPER')) {
77 if (/*overload*/mb_strlen($table)) {
78 // SHOW TABLES doesn't show temporary tables, so try select
79 // (as it can happen just in case temporary table, it should be
83 * @todo should this check really
84 * only happen if IS_TRANSFORMATION_WRAPPER?
86 $_result = $GLOBALS['dbi']->tryQuery(
87 'SELECT COUNT(*) FROM ' . PMA_Util
::backquote($table) . ';',
89 PMA_DatabaseInterface
::QUERY_STORE
91 $is_table = ($_result && @$GLOBALS['dbi']->numRows($_result));
92 $GLOBALS['dbi']->freeResult($_result);
96 include './db_sql.php';
105 } // end if (ensures table exists)