db_sql_autocomplete.php 746 B

123456789101112131415161718192021222324252627
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Table/Column autocomplete in SQL editors
  5. *
  6. * @package PhpMyAdmin
  7. */
  8. use PhpMyAdmin\Response;
  9. require_once 'libraries/common.inc.php';
  10. if ($GLOBALS['cfg']['EnableAutocompleteForTablesAndColumns']) {
  11. $db = isset($_POST['db']) ? $_POST['db'] : $GLOBALS['db'];
  12. $sql_autocomplete = array();
  13. if ($db) {
  14. $tableNames = $GLOBALS['dbi']->getTables($db);
  15. foreach ($tableNames as $tableName) {
  16. $sql_autocomplete[$tableName] = $GLOBALS['dbi']->getColumns(
  17. $db, $tableName
  18. );
  19. }
  20. }
  21. } else {
  22. $sql_autocomplete = true;
  23. }
  24. $response = Response::getInstance();
  25. $response->addJSON("tables", json_encode($sql_autocomplete));