Extracts db_common.inc.php code to the Common::database() method and removes the include file. Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
73 lines
1.9 KiB
PHP
73 lines
1.9 KiB
PHP
<?php
|
|
/**
|
|
* @package PhpMyAdmin\Controllers\Database
|
|
*/
|
|
declare(strict_types=1);
|
|
|
|
namespace PhpMyAdmin\Controllers\Database;
|
|
|
|
use PhpMyAdmin\Common;
|
|
use PhpMyAdmin\Config\PageSettings;
|
|
use PhpMyAdmin\DatabaseInterface;
|
|
use PhpMyAdmin\Response;
|
|
use PhpMyAdmin\SqlQueryForm;
|
|
use PhpMyAdmin\Template;
|
|
use PhpMyAdmin\Url;
|
|
|
|
/**
|
|
* Database SQL executor
|
|
*
|
|
* @package PhpMyAdmin\Controllers\Database
|
|
*/
|
|
class SqlController extends AbstractController
|
|
{
|
|
/** @var SqlQueryForm */
|
|
private $sqlQueryForm;
|
|
|
|
/**
|
|
* @param Response $response Response instance
|
|
* @param DatabaseInterface $dbi DatabaseInterface instance
|
|
* @param Template $template Template instance
|
|
* @param string $db Database name
|
|
* @param SqlQueryForm $sqlQueryForm SqlQueryForm instance
|
|
*/
|
|
public function __construct($response, $dbi, Template $template, $db, SqlQueryForm $sqlQueryForm)
|
|
{
|
|
parent::__construct($response, $dbi, $template, $db);
|
|
$this->sqlQueryForm = $sqlQueryForm;
|
|
}
|
|
|
|
/**
|
|
* @return void
|
|
*/
|
|
public function index(): void
|
|
{
|
|
global $goto, $back;
|
|
|
|
$header = $this->response->getHeader();
|
|
$scripts = $header->getScripts();
|
|
$scripts->addFile('makegrid.js');
|
|
$scripts->addFile('vendor/jquery/jquery.uitablefilter.js');
|
|
$scripts->addFile('sql.js');
|
|
|
|
PageSettings::showGroup('Sql');
|
|
|
|
Common::database();
|
|
|
|
/**
|
|
* After a syntax error, we return to this script
|
|
* with the typed query in the textarea.
|
|
*/
|
|
$goto = Url::getFromRoute('/database/sql');
|
|
$back = $goto;
|
|
|
|
$this->response->addHTML($this->sqlQueryForm->getHtml(
|
|
true,
|
|
false,
|
|
isset($_POST['delimiter'])
|
|
? htmlspecialchars($_POST['delimiter'])
|
|
: ';'
|
|
));
|
|
}
|
|
}
|