Merge branch 'QA_3_3'
[phpmyadmin/dkf.git] / libraries / db_common.inc.php
blob955e7c8c52444d0f6a7bb8b4b39caa01f5be848b
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
5 * @version $Id$
6 * @package phpMyAdmin
7 */
8 if (! defined('PHPMYADMIN')) {
9 exit;
12 /**
13 * Gets some core libraries
15 require_once './libraries/common.inc.php';
16 require_once './libraries/bookmark.lib.php';
18 PMA_checkParameters(array('db'));
20 $is_show_stats = $cfg['ShowStats'];
22 if ($db == 'information_schema') {
23 $is_show_stats = false;
24 $db_is_information_schema = true;
25 } else {
26 $db_is_information_schema = false;
29 /**
30 * Defines the urls to return to in case of error in a sql statement
32 $err_url_0 = 'main.php?' . PMA_generate_common_url();
33 $err_url = $cfg['DefaultTabDatabase'] . '?' . PMA_generate_common_url($db);
36 /**
37 * Ensures the database exists (else move to the "parent" script) and displays
38 * headers
40 if (!isset($is_db) || !$is_db) {
41 // Not a valid db name -> back to the welcome page
42 if (strlen($db)) {
43 $is_db = PMA_DBI_select_db($db);
45 if (! strlen($db) || !$is_db) {
46 PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . 'main.php?' . PMA_generate_common_url('', '', '&') . (isset($message) ? '&message=' . urlencode($message) : '') . '&reload=1');
47 exit;
49 } // end if (ensures db exists)
51 /**
52 * Changes database charset if requested by the user
54 if (isset($submitcollation) && !empty($db_collation)) {
55 list($db_charset) = explode('_', $db_collation);
56 $sql_query = 'ALTER DATABASE ' . PMA_backquote($db) . ' DEFAULT' . PMA_generateCharsetQueryPart($db_collation);
57 $result = PMA_DBI_query($sql_query);
58 $message = PMA_Message::success();
59 unset($db_charset, $db_collation);
62 $GLOBALS['js_include'][] = 'functions.js';
63 require_once './libraries/header.inc.php';
65 /**
66 * Set parameters for links
68 $url_query = PMA_generate_common_url($db);