Fix php 8.0 php notices - Undefined index
[phpmyadmin.git] / db_search.php
blob8efff1718a9bc54668ba1906f6537df5340bd1a7
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * searches the entire database
6 * @todo make use of UNION when searching multiple tables
7 * @todo display executed query, optional?
8 * @package PhpMyAdmin
9 */
11 use PhpMyAdmin\Database\Search;
12 use PhpMyAdmin\Response;
13 use PhpMyAdmin\Util;
15 /**
16 * Gets some core libraries
18 require_once 'libraries/common.inc.php';
20 $response = Response::getInstance();
21 $header = $response->getHeader();
22 $scripts = $header->getScripts();
23 $scripts->addFile('db_search.js');
24 $scripts->addFile('sql.js');
25 $scripts->addFile('makegrid.js');
27 require 'libraries/db_common.inc.php';
29 // If config variable $GLOBALS['cfg']['UseDbSearch'] is on false : exit.
30 if (! $GLOBALS['cfg']['UseDbSearch']) {
31 Util::mysqlDie(
32 __('Access denied!'), '', false, $err_url
34 } // end if
35 $url_query .= '&amp;goto=db_search.php';
36 $url_params['goto'] = 'db_search.php';
38 // Create a database search instance
39 $db_search = new Search($GLOBALS['db']);
41 // Display top links if we are not in an Ajax request
42 if (! $response->isAjax()) {
43 list(
44 $tables,
45 $num_tables,
46 $total_num_tables,
47 $sub_part,
48 $is_show_stats,
49 $db_is_system_schema,
50 $tooltip_truename,
51 $tooltip_aliasname,
52 $pos
53 ) = Util::getDbInfo($db, isset($sub_part) ? $sub_part : '');
56 // Main search form has been submitted, get results
57 if (isset($_POST['submit_search'])) {
58 $response->addHTML($db_search->getSearchResults());
61 // If we are in an Ajax request, we need to exit after displaying all the HTML
62 if ($response->isAjax() && empty($_REQUEST['ajax_page_request'])) {
63 exit;
66 // Display the search form
67 $response->addHTML($db_search->getSelectionForm());
68 $response->addHTML('<div id="searchresults"></div>');
69 $response->addHTML(
70 '<div id="togglesearchresultsdiv"><a id="togglesearchresultlink"></a></div>'
72 $response->addHTML('<br class="clearfloat" />');
73 $response->addHTML($db_search->getResultDivs());