[ Index ]
 

Code source de phpMyAdmin 2.10.3

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/libraries/ -> db_table_exists.lib.php (source)

   1  <?php
   2  /* $Id: db_table_exists.lib.php 9636 2006-10-27 13:04:15Z nijel $ */
   3  // vim: expandtab sw=4 ts=4 sts=4:
   4  
   5  /**
   6   * Ensure the database and the table exist (else move to the "parent" script)
   7   * and display headers
   8   */
   9  if (empty($is_db)) {
  10      if (isset($db) && strlen($db)) {
  11          $is_db = @PMA_DBI_select_db($db);
  12      } else {
  13          $is_db = false;
  14      }
  15  
  16      if (! $is_db) {
  17          // not a valid db name -> back to the welcome page
  18          if (! defined('IS_TRANSFORMATION_WRAPPER')) {
  19              $url_params = array('reload' => 1);
  20              if (isset($message)) {
  21                  $url_params['message'] = $message;
  22              }
  23              if (isset($sql_query)) {
  24                  $url_params['sql_query'] = $sql_query;
  25              }
  26              if (isset($show_as_php)) {
  27                  $url_params['show_as_php'] = $show_as_php;
  28              }
  29              PMA_sendHeaderLocation(
  30                  $cfg['PmaAbsoluteUri'] . 'main.php'
  31                      . PMA_generate_common_url($url_params, '&'));
  32          }
  33          exit;
  34      }
  35  } // end if (ensures db exists)
  36  
  37  if (empty($is_table) && !defined('PMA_SUBMIT_MULT')) {
  38      // Not a valid table name -> back to the db_sql.php
  39      if (isset($table) && strlen($table)) {
  40          $_result = PMA_DBI_try_query(
  41              'SHOW TABLES LIKE \'' . PMA_sqlAddslashes($table, true) . '\';',
  42              null, PMA_DBI_QUERY_STORE);
  43          $is_table = @PMA_DBI_num_rows($_result);
  44          PMA_DBI_free_result($_result);
  45      } else {
  46          $is_table = false;
  47      }
  48  
  49      if (! $is_table) {
  50          if (! defined('IS_TRANSFORMATION_WRAPPER')) {
  51              if (isset($table) && strlen($table)) {
  52                  // SHOW TABLES doesn't show temporary tables, so try select
  53                  // (as it can happen just in case temporary table, it should be
  54                  // fast):
  55  
  56                  /**
  57                   * @todo should this check really only happen if IS_TRANSFORMATION_WRAPPER?
  58                   */
  59                  $_result = PMA_DBI_try_query(
  60                      'SELECT COUNT(*) FROM `' . PMA_sqlAddslashes($table, true) . '`;',
  61                      null, PMA_DBI_QUERY_STORE);
  62                  $is_table = ($_result && @PMA_DBI_num_rows($_result));
  63                  PMA_DBI_free_result($_result);
  64              }
  65  
  66              if (! $is_table) {
  67                  $url_params = array('reload' => 1, 'db' => $db);
  68                  if (isset($message)) {
  69                      $url_params['message'] = $message;
  70                  }
  71                  if (isset($sql_query)) {
  72                      $url_params['sql_query'] = $sql_query;
  73                  }
  74                  if (isset($display_query)) {
  75                      $url_params['display_query'] = $display_query;
  76                  }
  77                  PMA_sendHeaderLocation(
  78                      $cfg['PmaAbsoluteUri'] . 'db_sql.php'
  79                          . PMA_generate_common_url($url_params, '&'));
  80              }
  81          }
  82  
  83          if (! $is_table) {
  84              exit;
  85          }
  86      }
  87  } // end if (ensures table exists)
  88  ?>


Généré le : Mon Nov 26 15:18:20 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics