Translated using Weblate (Armenian)
[phpmyadmin.git] / db_search.php
blob7a3c3f37abb16ffd8aad20db1c959225d82b99ac
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\Response;
15 use PhpMyAdmin\Template;
16 use PhpMyAdmin\Util;
18 if (! defined('ROOT_PATH')) {
19 define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
22 global $db, $url_query;
24 require_once ROOT_PATH . 'libraries/common.inc.php';
26 /** @var Response $response */
27 $response = $containerBuilder->get(Response::class);
29 /** @var DatabaseInterface $dbi */
30 $dbi = $containerBuilder->get(DatabaseInterface::class);
32 /** @var Template $template */
33 $template = $containerBuilder->get('template');
35 $header = $response->getHeader();
36 $scripts = $header->getScripts();
37 $scripts->addFile('database/search.js');
38 $scripts->addFile('vendor/stickyfill.min.js');
39 $scripts->addFile('sql.js');
40 $scripts->addFile('makegrid.js');
42 require ROOT_PATH . 'libraries/db_common.inc.php';
44 // If config variable $GLOBALS['cfg']['UseDbSearch'] is on false : exit.
45 if (! $GLOBALS['cfg']['UseDbSearch']) {
46 Util::mysqlDie(
47 __('Access denied!'),
48 '',
49 false,
50 $err_url
52 } // end if
53 $url_query .= '&amp;goto=db_search.php';
54 $url_params['goto'] = 'db_search.php';
56 // Create a database search instance
57 $db_search = new Search($dbi, $db, $template);
59 // Display top links if we are not in an Ajax request
60 if (! $response->isAjax()) {
61 list(
62 $tables,
63 $num_tables,
64 $total_num_tables,
65 $sub_part,
66 $is_show_stats,
67 $db_is_system_schema,
68 $tooltip_truename,
69 $tooltip_aliasname,
70 $pos
71 ) = Util::getDbInfo($db, isset($sub_part) ? $sub_part : '');
74 // Main search form has been submitted, get results
75 if (isset($_POST['submit_search'])) {
76 $response->addHTML($db_search->getSearchResults());
79 // If we are in an Ajax request, we need to exit after displaying all the HTML
80 if ($response->isAjax() && empty($_REQUEST['ajax_page_request'])) {
81 exit;
84 // Display the search form
85 $response->addHTML($db_search->getMainHtml());