Translated using Weblate (Slovenian)
[phpmyadmin.git] / db_qbe.php
blobf027cac32cb2786ae01863cc9f34ca1d0a44ba86
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * query by example the whole database
6 * @package PhpMyAdmin
7 */
9 /**
10 * requirements
12 require_once 'libraries/common.inc.php';
13 require_once 'libraries/DBQbe.class.php';
14 require_once 'libraries/bookmark.lib.php';
15 require_once 'libraries/sql.lib.php';
17 $response = PMA_Response::getInstance();
19 // Gets the relation settings
20 $cfgRelation = PMA_getRelationsParam();
22 $savedSearchList = array();
23 $savedSearch = null;
24 $currentSearchId = null;
25 if (isset($cfgRelation['savedsearcheswork']) && $cfgRelation['savedsearcheswork']) {
26 include 'libraries/SavedSearches.class.php';
27 $header = $response->getHeader();
28 $scripts = $header->getScripts();
29 $scripts->addFile('db_qbe.js');
31 //Get saved search list.
32 $savedSearch = new PMA_SavedSearches($GLOBALS);
33 $savedSearch->setUsername($GLOBALS['cfg']['Server']['user'])
34 ->setDbname($_REQUEST['db']);
36 if (!empty($_REQUEST['searchId'])) {
37 $savedSearch->setId($_REQUEST['searchId']);
40 //Action field is sent.
41 if (isset($_REQUEST['action'])) {
42 $savedSearch->setSearchName($_REQUEST['searchName']);
43 if ('create' === $_REQUEST['action']) {
44 $saveResult = $savedSearch->setId(null)
45 ->setCriterias($_REQUEST)
46 ->save();
47 } elseif ('update' === $_REQUEST['action']) {
48 $saveResult = $savedSearch->setCriterias($_REQUEST)
49 ->save();
50 } elseif ('delete' === $_REQUEST['action']) {
51 $deleteResult = $savedSearch->delete();
52 //After deletion, reset search.
53 $savedSearch = new PMA_SavedSearches($GLOBALS);
54 $savedSearch->setUsername($GLOBALS['cfg']['Server']['user'])
55 ->setDbname($_REQUEST['db']);
56 $_REQUEST = array();
57 } elseif ('load' === $_REQUEST['action']) {
58 if (empty($_REQUEST['searchId'])) {
59 //when not loading a search, reset the object.
60 $savedSearch = new PMA_SavedSearches($GLOBALS);
61 $savedSearch->setUsername($GLOBALS['cfg']['Server']['user'])
62 ->setDbname($_REQUEST['db']);
63 $_REQUEST = array();
64 } else {
65 $loadResult = $savedSearch->load();
68 //Else, it's an "update query"
71 $savedSearchList = $savedSearch->getList();
72 $currentSearchId = $savedSearch->getId();
75 /**
76 * A query has been submitted -> (maybe) execute it
78 $message_to_display = false;
79 if (isset($_REQUEST['submit_sql']) && ! empty($sql_query)) {
80 if (! preg_match('@^SELECT@i', $sql_query)) {
81 $message_to_display = true;
82 } else {
83 $goto = 'db_sql.php';
85 // Parse and analyze the query
86 include_once 'libraries/parse_analyze.inc.php';
88 PMA_executeQueryAndSendQueryResponse(
89 $analyzed_sql_results, false, $_REQUEST['db'], null, false, null, null,
90 false, null, null, null, $goto, $pmaThemeImage, null, null, null,
91 $sql_query, null, null
96 $sub_part = '_qbe';
97 require 'libraries/db_common.inc.php';
98 $url_query .= '&amp;goto=db_qbe.php';
99 $url_params['goto'] = 'db_qbe.php';
100 require 'libraries/db_info.inc.php';
102 if ($message_to_display) {
103 PMA_Message::error(__('You have to choose at least one column to display!'))
104 ->display();
106 unset($message_to_display);
108 // create new qbe search instance
109 $db_qbe = new PMA_DbQbe($GLOBALS['db'], $savedSearchList, $savedSearch);
112 * Displays the Query by example form
114 if ($cfgRelation['pdfwork']) {
115 $url = 'db_designer.php' . PMA_URL_getCommon(
116 array_merge(
117 $url_params,
118 array('query' => 1)
121 $response->addHTML(
122 PMA_Message::notice(
123 sprintf(
124 __('Switch to %svisual builder%s'),
125 '<a href="' . $url . '">',
126 '</a>'
132 $response->addHTML($db_qbe->getSelectionForm());