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