2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Table/Column autocomplete in SQL editors
8 declare(strict_types
=1);
10 use PhpMyAdmin\DatabaseInterface
;
11 use PhpMyAdmin\Di\Container
;
12 use PhpMyAdmin\Response
;
14 if (! defined('ROOT_PATH')) {
15 define('ROOT_PATH', __DIR__
. DIRECTORY_SEPARATOR
);
18 require_once ROOT_PATH
. 'libraries/common.inc.php';
20 $container = Container
::getDefaultContainer();
21 $container->set(Response
::class, Response
::getInstance());
23 /** @var Response $response */
24 $response = $container->get(Response
::class);
26 /** @var DatabaseInterface $dbi */
27 $dbi = $container->get(DatabaseInterface
::class);
29 if ($GLOBALS['cfg']['EnableAutocompleteForTablesAndColumns']) {
30 $db = isset($_POST['db']) ?
$_POST['db'] : $GLOBALS['db'];
31 $sql_autocomplete = [];
33 $tableNames = $dbi->getTables($db);
34 foreach ($tableNames as $tableName) {
35 $sql_autocomplete[$tableName] = $dbi->getColumns(
42 $sql_autocomplete = true;
45 $response->addJSON("tables", json_encode($sql_autocomplete));