Translated using Weblate (German)
[phpmyadmin.git] / db_search.php
blob4ba97f6461b4b487cea2de260090e6473e528d12
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 */
10 declare(strict_types=1);
12 use PhpMyAdmin\Database\Search;
13 use PhpMyAdmin\DatabaseInterface;
14 use PhpMyAdmin\Di\Container;
15 use PhpMyAdmin\Response;
16 use PhpMyAdmin\Util;
18 if (! defined('ROOT_PATH')) {
19 define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
22 require_once ROOT_PATH . 'libraries/common.inc.php';
24 $container = Container::getDefaultContainer();
25 $container->set(Response::class, Response::getInstance());
27 /** @var Response $response */
28 $response = $container->get(Response::class);
30 /** @var DatabaseInterface $dbi */
31 $dbi = $container->get(DatabaseInterface::class);
33 $header = $response->getHeader();
34 $scripts = $header->getScripts();
35 $scripts->addFile('db_search.js');
36 $scripts->addFile('sql.js');
37 $scripts->addFile('makegrid.js');
39 require ROOT_PATH . 'libraries/db_common.inc.php';
41 // If config variable $GLOBALS['cfg']['UseDbSearch'] is on false : exit.
42 if (! $GLOBALS['cfg']['UseDbSearch']) {
43 Util::mysqlDie(
44 __('Access denied!'),
45 '',
46 false,
47 $err_url
49 } // end if
50 $url_query .= '&amp;goto=db_search.php';
51 $url_params['goto'] = 'db_search.php';
53 // Create a database search instance
54 $db_search = new Search($dbi, $GLOBALS['db']);
56 // Display top links if we are not in an Ajax request
57 if (! $response->isAjax()) {
58 list(
59 $tables,
60 $num_tables,
61 $total_num_tables,
62 $sub_part,
63 $is_show_stats,
64 $db_is_system_schema,
65 $tooltip_truename,
66 $tooltip_aliasname,
67 $pos
68 ) = Util::getDbInfo($db, isset($sub_part) ? $sub_part : '');
71 // Main search form has been submitted, get results
72 if (isset($_POST['submit_search'])) {
73 $response->addHTML($db_search->getSearchResults());
76 // If we are in an Ajax request, we need to exit after displaying all the HTML
77 if ($response->isAjax() && empty($_REQUEST['ajax_page_request'])) {
78 exit;
81 // Display the search form
82 $response->addHTML($db_search->getMainHtml());