1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-06 14:46:36 +02:00

Use connection() instead of $connection

This commit is contained in:
Jakub Vrana
2025-03-29 21:16:28 +01:00
parent 168ea5ae6d
commit 712d96b22c
36 changed files with 130 additions and 196 deletions

View File

@@ -31,8 +31,7 @@ class Adminer {
}
function database() {
global $connection;
if ($connection) {
if (connection()) {
$databases = adminer()->databases(false);
return (!$databases
? get_val("SELECT SUBSTRING_INDEX(CURRENT_USER, '@', 1)") // username without the database list
@@ -558,8 +557,7 @@ ORDER BY ORDINAL_POSITION", null, "") as $row
}
function dumpData($table, $style, $query) {
global $connection;
$result = $connection->query($query, 1); // 1 - MYSQLI_USE_RESULT
$result = connection()->query($query, 1); // 1 - MYSQLI_USE_RESULT
if ($result) {
while ($row = $result->fetch_assoc()) {
if ($style == "table") {

View File

@@ -1,4 +1,4 @@
<?php
namespace Adminer;
$connection->select_db(adminer()->database());
connection()->select_db(adminer()->database());

View File

@@ -2,11 +2,11 @@
namespace Adminer;
if ($_GET["script"] == "kill") {
$connection->query("KILL " . number($_POST["kill"]));
connection()->query("KILL " . number($_POST["kill"]));
} elseif (list($table, $id, $name) = adminer()->_foreignColumn(column_foreign_keys($_GET["source"]), $_GET["field"])) { // complete
$limit = 11;
$result = $connection->query("SELECT $id, $name FROM " . table($table) . " WHERE " . (preg_match('~^[0-9]+$~', $_GET["value"]) ? "$id = $_GET[value] OR " : "") . "$name LIKE " . q("$_GET[value]%") . " ORDER BY 2 LIMIT $limit");
$result = connection()->query("SELECT $id, $name FROM " . table($table) . " WHERE " . (preg_match('~^[0-9]+$~', $_GET["value"]) ? "$id = $_GET[value] OR " : "") . "$name LIKE " . q("$_GET[value]%") . " ORDER BY 2 LIMIT $limit");
for ($i=1; ($row = $result->fetch_row()) && $i < $limit; $i++) {
echo "<a href='" . h(ME . "edit=" . urlencode($table) . "&where" . urlencode("[" . bracket_escape(idf_unescape($id)) . "]") . "=" . urlencode($row[0])) . "'>" . h($row[1]) . "</a><br>\n";
}