Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moves database sql autocomplete entry point logic to the Database\SqlAutoCompleteController and removes the entry point file. Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
- Loading branch information
1 parent
fa6fc40
commit 301835e
Showing
4 changed files
with
52 additions
and
43 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
libraries/classes/Controllers/Database/SqlAutoCompleteController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
/** | ||
* @package PhpMyAdmin\Controllers\Database | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace PhpMyAdmin\Controllers\Database; | ||
|
||
/** | ||
* Table/Column autocomplete in SQL editors. | ||
* @package PhpMyAdmin\Controllers\Database | ||
*/ | ||
class SqlAutoCompleteController extends AbstractController | ||
{ | ||
/** | ||
* @return array JSON | ||
*/ | ||
public function index(): array | ||
{ | ||
global $cfg, $db, $sql_autocomplete; | ||
|
||
$sql_autocomplete = true; | ||
if ($cfg['EnableAutocompleteForTablesAndColumns']) { | ||
$db = isset($_POST['db']) ? $_POST['db'] : $db; | ||
$sql_autocomplete = []; | ||
if ($db) { | ||
$tableNames = $this->dbi->getTables($db); | ||
foreach ($tableNames as $tableName) { | ||
$sql_autocomplete[$tableName] = $this->dbi->getColumns( | ||
$db, | ||
$tableName | ||
); | ||
} | ||
} | ||
} | ||
return ['tables' => json_encode($sql_autocomplete)]; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters