2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * searches the entire database
6 * @todo make use of UNION when searching multiple tables
7 * @todo display executed query, optional?
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\Template
;
19 if (! defined('ROOT_PATH')) {
20 define('ROOT_PATH', __DIR__
. DIRECTORY_SEPARATOR
);
23 global $db, $url_query;
25 require_once ROOT_PATH
. 'libraries/common.inc.php';
27 $container = Container
::getDefaultContainer();
28 $container->set(Response
::class, Response
::getInstance());
30 /** @var Response $response */
31 $response = $container->get(Response
::class);
33 /** @var DatabaseInterface $dbi */
34 $dbi = $container->get(DatabaseInterface
::class);
36 /** @var Template $template */
37 $template = $containerBuilder->get('template');
39 $header = $response->getHeader();
40 $scripts = $header->getScripts();
41 $scripts->addFile('db_search.js');
42 $scripts->addFile('sql.js');
43 $scripts->addFile('makegrid.js');
45 require ROOT_PATH
. 'libraries/db_common.inc.php';
47 // If config variable $GLOBALS['cfg']['UseDbSearch'] is on false : exit.
48 if (! $GLOBALS['cfg']['UseDbSearch']) {
56 $url_query .= '&goto=db_search.php';
57 $url_params['goto'] = 'db_search.php';
59 // Create a database search instance
60 $db_search = new Search($dbi, $db, $template);
62 // Display top links if we are not in an Ajax request
63 if (! $response->isAjax()) {
74 ) = Util
::getDbInfo($db, isset($sub_part) ?
$sub_part : '');
77 // Main search form has been submitted, get results
78 if (isset($_POST['submit_search'])) {
79 $response->addHTML($db_search->getSearchResults());
82 // If we are in an Ajax request, we need to exit after displaying all the HTML
83 if ($response->isAjax() && empty($_REQUEST['ajax_page_request'])) {
87 // Display the search form
88 $response->addHTML($db_search->getMainHtml());