* Add native property types Includes TypeHints.UnionTypeHintFormat Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Set some default values for properties Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Format and promote properties Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Remove redundant asserts Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Redundant cast Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * $tmanager->theme is never null Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Redundant variable Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Fix empty on $statementInfo bool Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Redundant casts Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Redundant issets Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * getPacked() returns nullable string Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Redundant if Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * $this->content can be null Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Simplify ThemeManager::getInstance() Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Use isset for checking if property is initialized Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Use nullable instead of uninitialized property Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * password is no longer nullable I can't verify that none of the globals ever tried to set it to null, but the variable should never be nullable. Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Update baselines Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * $same_wide_width param can be float or int Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Update Message.php Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Cast Sub_part to int Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Fix one line doc comments Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> --------- Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
106 lines
2.6 KiB
PHP
106 lines
2.6 KiB
PHP
<?php
|
|
/**
|
|
* Handles DB Multi-table query
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace PhpMyAdmin\Database;
|
|
|
|
use PhpMyAdmin\ConfigStorage\Relation;
|
|
use PhpMyAdmin\ConfigStorage\RelationCleanup;
|
|
use PhpMyAdmin\DatabaseInterface;
|
|
use PhpMyAdmin\Operations;
|
|
use PhpMyAdmin\ParseAnalyze;
|
|
use PhpMyAdmin\Sql;
|
|
use PhpMyAdmin\Template;
|
|
use PhpMyAdmin\Transformations;
|
|
use PhpMyAdmin\Url;
|
|
|
|
use function array_keys;
|
|
use function md5;
|
|
|
|
/**
|
|
* Class to handle database Multi-table querying
|
|
*/
|
|
class MultiTableQuery
|
|
{
|
|
/**
|
|
* Table names
|
|
*
|
|
* @var array<int, string>
|
|
*/
|
|
private array $tables;
|
|
|
|
public function __construct(
|
|
private DatabaseInterface $dbi,
|
|
public Template $template,
|
|
private string $db,
|
|
private int $defaultNoOfColumns = 3,
|
|
) {
|
|
$this->tables = $this->dbi->getTables($this->db);
|
|
}
|
|
|
|
/**
|
|
* Get Multi-Table query page HTML
|
|
*
|
|
* @return string Multi-Table query page HTML
|
|
*/
|
|
public function getFormHtml(): string
|
|
{
|
|
$tables = [];
|
|
foreach ($this->tables as $table) {
|
|
$tables[$table]['hash'] = md5($table);
|
|
$tables[$table]['columns'] = array_keys(
|
|
$this->dbi->getColumns($this->db, $table),
|
|
);
|
|
}
|
|
|
|
return $this->template->render('database/multi_table_query/form', [
|
|
'db' => $this->db,
|
|
'tables' => $tables,
|
|
'default_no_of_columns' => $this->defaultNoOfColumns,
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Displays multi-table query results
|
|
*
|
|
* @param string $sqlQuery The query to parse
|
|
* @param string $db The current database
|
|
*/
|
|
public static function displayResults($sqlQuery, $db): string
|
|
{
|
|
[, $db] = ParseAnalyze::sqlQuery($sqlQuery, $db);
|
|
|
|
$goto = Url::getFromRoute('/database/multi-table-query');
|
|
|
|
$relation = new Relation($GLOBALS['dbi']);
|
|
$sql = new Sql(
|
|
$GLOBALS['dbi'],
|
|
$relation,
|
|
new RelationCleanup($GLOBALS['dbi'], $relation),
|
|
new Operations($GLOBALS['dbi'], $relation),
|
|
new Transformations(),
|
|
new Template(),
|
|
);
|
|
|
|
return $sql->executeQueryAndSendQueryResponse(
|
|
null,
|
|
false, // is_gotofile
|
|
$db, // db
|
|
null, // table
|
|
null, // find_real_end
|
|
null, // sql_query_for_bookmark - see below
|
|
null, // extra_data
|
|
null, // message_to_show
|
|
null, // sql_data
|
|
$goto, // goto
|
|
null, // disp_query
|
|
null, // disp_message
|
|
$sqlQuery, // sql_query
|
|
null, // complete_query
|
|
);
|
|
}
|
|
}
|