Translated using Weblate (Slovenian)
[phpmyadmin.git] / db_sql_autocomplete.php
blobbac726590c7f912abc6798ee5c0c3ebdfc8a92fb
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Table/Column autocomplete in SQL editors
6 * @package PhpMyAdmin
7 */
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 = [];
32 if ($db) {
33 $tableNames = $dbi->getTables($db);
34 foreach ($tableNames as $tableName) {
35 $sql_autocomplete[$tableName] = $dbi->getColumns(
36 $db,
37 $tableName
41 } else {
42 $sql_autocomplete = true;
45 $response->addJSON("tables", json_encode($sql_autocomplete));