Translation update done using Pootle.
[phpmyadmin/madhuracj.git] / libraries / db_common.inc.php
blob5a3c4f73a237ada37aed1ca078d939ce511d3b9d
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
5 * @package PhpMyAdmin
6 */
7 if (! defined('PHPMYADMIN')) {
8 exit;
11 /**
12 * Gets some core libraries
14 require_once './libraries/common.inc.php';
15 require_once './libraries/bookmark.lib.php';
17 PMA_checkParameters(array('db'));
19 $is_show_stats = $cfg['ShowStats'];
21 $db_is_information_schema = PMA_is_system_schema($db);
22 if ($db_is_information_schema) {
23 $is_show_stats = false;
26 /**
27 * Defines the urls to return to in case of error in a sql statement
29 $err_url_0 = 'main.php?' . PMA_generate_common_url();
30 $err_url = $cfg['DefaultTabDatabase'] . '?' . PMA_generate_common_url($db);
33 /**
34 * Ensures the database exists (else move to the "parent" script) and displays
35 * headers
37 if (! isset($is_db) || ! $is_db) {
38 if (strlen($db)) {
39 $is_db = PMA_DBI_select_db($db);
40 // This "Command out of sync" 2014 error may happen, for example
41 // after calling a MySQL procedure; at this point we can't select
42 // the db but it's not necessarily wrong
43 if (PMA_DBI_getError() && $GLOBALS['errno'] == 2014) {
44 $is_db = true;
45 unset($GLOBALS['errno']);
48 // Not a valid db name -> back to the welcome page
49 if (! strlen($db) || ! $is_db) {
50 PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . 'main.php?' . PMA_generate_common_url('', '', '&') . (isset($message) ? '&message=' . urlencode($message) : '') . '&reload=1');
51 exit;
53 } // end if (ensures db exists)
55 /**
56 * Changes database charset if requested by the user
58 if (isset($submitcollation) && !empty($db_collation)) {
59 list($db_charset) = explode('_', $db_collation);
60 $sql_query = 'ALTER DATABASE ' . PMA_backquote($db) . ' DEFAULT' . PMA_generateCharsetQueryPart($db_collation);
61 $result = PMA_DBI_query($sql_query);
62 $message = PMA_Message::success();
63 unset($db_charset, $db_collation);
65 /**
66 * If we are in an Ajax request, let us stop the execution here. Necessary for
67 * db charset change action on db_operations.php. If this causes a bug on
68 * other pages, we might have to move this to a different location.
70 if ( $GLOBALS['is_ajax_request'] == true) {
71 PMA_ajaxResponse($message, $message->isSuccess());
75 require_once './libraries/header.inc.php';
77 /**
78 * Set parameters for links
80 $url_query = PMA_generate_common_url($db);