Visitar URL original
Merge pull request #17253 from kamil-tekiela/fetchValue · phpmyadmin/phpmyadmin@4e0141e · GitHub
Skip to content

Commit 4e0141e

Browse files
Merge pull request #17253 from kamil-tekiela/fetchValue
Remove $row_number from DatabaseInterface::fetchValue
2 parents bfa5ee9 + 70c86f5 commit 4e0141e

14 files changed

Lines changed: 33 additions & 56 deletions

File tree

‎libraries/classes/ConfigStorage/Relation.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,7 @@ public function purgeHistory($username): void
819819
ORDER BY `timevalue` DESC
820820
LIMIT ' . $GLOBALS['cfg']['QueryHistoryMax'] . ', 1';
821821

822-
$max_time = $this->dbi->fetchValue($search_query, 0, 0, DatabaseInterface::CONNECT_CONTROL);
822+
$max_time = $this->dbi->fetchValue($search_query, 0, DatabaseInterface::CONNECT_CONTROL);
823823

824824
if (! $max_time) {
825825
return;

‎libraries/classes/Controllers/Server/UserGroupsFormController.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ private function getHtmlToChooseUserGroup(string $username, RelationParameters $
8181
$userTable,
8282
$this->dbi->escapeString($username)
8383
);
84-
$userGroup = $this->dbi->fetchValue($sqlQuery, 0, 0, DatabaseInterface::CONNECT_CONTROL);
84+
$userGroup = $this->dbi->fetchValue($sqlQuery, 0, DatabaseInterface::CONNECT_CONTROL);
8585

8686
$allUserGroups = [];
8787
$sqlQuery = 'SELECT DISTINCT `usergroup` FROM ' . $groupTable;

‎libraries/classes/Database/Events.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ public function getQueryFromRequest()
479479

480480
public function getEventSchedulerStatus(): bool
481481
{
482-
$state = (string) $this->dbi->fetchValue('SHOW GLOBAL VARIABLES LIKE \'event_scheduler\'', 0, 1);
482+
$state = (string) $this->dbi->fetchValue('SHOW GLOBAL VARIABLES LIKE \'event_scheduler\'', 1);
483483

484484
return strtoupper($state) === 'ON' || $state === '1';
485485
}

‎libraries/classes/DatabaseInterface.php‎

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,7 @@ public function getVariable(
10301030
$modifier = '';
10311031
}
10321032

1033-
return $this->fetchValue('SHOW' . $modifier . ' VARIABLES LIKE \'' . $var . '\';', 0, 1, $link);
1033+
return $this->fetchValue('SHOW' . $modifier . ' VARIABLES LIKE \'' . $var . '\';', 1, $link);
10341034
}
10351035

10361036
/**
@@ -1200,18 +1200,15 @@ public function postConnectControl(Relation $relation): void
12001200
* // $user_name = 'John Doe'
12011201
* </code>
12021202
*
1203-
* @param string $query The query to execute
1204-
* @param int $row_number row to fetch the value from,
1205-
* starting at 0, with 0 being default
1206-
* @param int|string $field field to fetch the value from,
1207-
* starting at 0, with 0 being default
1208-
* @param int $link link type
1203+
* @param string $query The query to execute
1204+
* @param int|string $field field to fetch the value from,
1205+
* starting at 0, with 0 being default
1206+
* @param int $link link type
12091207
*
12101208
* @return mixed|false value of first field in first row from result or false if not found
12111209
*/
12121210
public function fetchValue(
12131211
string $query,
1214-
int $row_number = 0,
12151212
$field = 0,
12161213
$link = self::CONNECT_USER
12171214
) {
@@ -1220,14 +1217,7 @@ public function fetchValue(
12201217
return false;
12211218
}
12221219

1223-
// return false if result is empty or false
1224-
// or requested row is larger than rows in result
1225-
if ($this->numRows($result) < $row_number + 1) {
1226-
return false;
1227-
}
1228-
12291220
// get requested row
1230-
$this->dataSeek($result, $row_number);
12311221
$row = $this->fetchByMode($result, is_int($field) ? self::FETCH_NUM : self::FETCH_ASSOC);
12321222

12331223
// return requested field
@@ -1507,7 +1497,7 @@ public function getDefinition(
15071497
$query = 'SHOW CREATE ' . $which . ' '
15081498
. Util::backquote($db) . '.'
15091499
. Util::backquote($name);
1510-
$result = $this->fetchValue($query, 0, $returned_field[$which], $link);
1500+
$result = $this->fetchValue($query, $returned_field[$which], $link);
15111501

15121502
return is_string($result) ? $result : null;
15131503
}
@@ -2113,7 +2103,7 @@ public function insertId($link = self::CONNECT_USER)
21132103
// When no controluser is defined, using mysqli_insert_id($link)
21142104
// does not always return the last insert id due to a mixup with
21152105
// the tracking mechanism, but this works:
2116-
return $this->fetchValue('SELECT LAST_INSERT_ID();', 0, 0, $link);
2106+
return $this->fetchValue('SELECT LAST_INSERT_ID();', 0, $link);
21172107
}
21182108

21192109
/**

‎libraries/classes/Dbal/DbalInterface.php‎

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -302,21 +302,17 @@ public function postConnectControl(Relation $relation): void;
302302
* // $user_name = 'John Doe'
303303
* </code>
304304
*
305-
* @param string $query The query to execute
306-
* @param int $row_number row to fetch the value from,
307-
* starting at 0, with 0 being
308-
* default
309-
* @param int|string $field field to fetch the value from,
310-
* starting at 0, with 0 being
311-
* default
312-
* @param int $link link type
305+
* @param string $query The query to execute
306+
* @param int|string $field field to fetch the value from,
307+
* starting at 0, with 0 being
308+
* default
309+
* @param int $link link type
313310
*
314311
* @return mixed value of first field in first row from result
315312
* or false if not found
316313
*/
317314
public function fetchValue(
318315
string $query,
319-
int $row_number = 0,
320316
$field = 0,
321317
$link = DatabaseInterface::CONNECT_USER
322318
);

‎libraries/classes/Engines/Innodb.php‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,6 @@ public function getPageStatus()
266266
return '<pre id="pre_innodb_status">' . "\n"
267267
. htmlspecialchars((string) $dbi->fetchValue(
268268
'SHOW ENGINE INNODB STATUS;',
269-
0,
270269
'Status'
271270
)) . "\n" . '</pre>' . "\n";
272271
}
@@ -305,7 +304,7 @@ public function getInnodbFileFormat(): ?string
305304
{
306305
global $dbi;
307306

308-
$value = $dbi->fetchValue("SHOW GLOBAL VARIABLES LIKE 'innodb_file_format';", 0, 1);
307+
$value = $dbi->fetchValue("SHOW GLOBAL VARIABLES LIKE 'innodb_file_format';", 1);
309308

310309
if ($value === false) {
311310
// This variable does not exist anymore on MariaDB >= 10.6.0
@@ -325,6 +324,6 @@ public function supportsFilePerTable(): bool
325324
{
326325
global $dbi;
327326

328-
return $dbi->fetchValue("SHOW GLOBAL VARIABLES LIKE 'innodb_file_per_table';", 0, 1) === 'ON';
327+
return $dbi->fetchValue("SHOW GLOBAL VARIABLES LIKE 'innodb_file_per_table';", 1) === 'ON';
329328
}
330329
}

‎libraries/classes/Server/Privileges.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ public function setUserGroup($username, $userGroup): void
561561

562562
$sqlQuery = 'SELECT `usergroup` FROM ' . $userTable
563563
. " WHERE `username` = '" . $this->dbi->escapeString($username) . "'";
564-
$oldUserGroup = $this->dbi->fetchValue($sqlQuery, 0, 0, DatabaseInterface::CONNECT_CONTROL);
564+
$oldUserGroup = $this->dbi->fetchValue($sqlQuery, 0, DatabaseInterface::CONNECT_CONTROL);
565565

566566
if ($oldUserGroup === false) {
567567
$updQuery = 'INSERT INTO ' . $userTable . '(`username`, `usergroup`)'
@@ -1557,7 +1557,7 @@ public function getUserGroupCount(): int
15571557
. '.' . Util::backquote($relationParameters->usergroups);
15581558
$sqlQuery = 'SELECT COUNT(*) FROM ' . $userGroupTable;
15591559

1560-
return (int) $this->dbi->fetchValue($sqlQuery, 0, 0, DatabaseInterface::CONNECT_CONTROL);
1560+
return (int) $this->dbi->fetchValue($sqlQuery, 0, DatabaseInterface::CONNECT_CONTROL);
15611561
}
15621562

15631563
/**
@@ -1581,7 +1581,7 @@ public function getUserGroupForUser($username)
15811581
. ' WHERE `username` = \'' . $username . '\''
15821582
. ' LIMIT 1';
15831583

1584-
$usergroup = $this->dbi->fetchValue($sqlQuery, 0, 0, DatabaseInterface::CONNECT_CONTROL);
1584+
$usergroup = $this->dbi->fetchValue($sqlQuery, 0, DatabaseInterface::CONNECT_CONTROL);
15851585

15861586
if ($usergroup === false) {
15871587
return null;

‎libraries/classes/Table.php‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2614,7 +2614,6 @@ public function showCreate()
26142614
return $this->dbi->fetchValue(
26152615
'SHOW CREATE TABLE ' . Util::backquote($this->dbName) . '.'
26162616
. Util::backquote($this->name),
2617-
0,
26182617
1
26192618
);
26202619
}

‎libraries/classes/Tracker.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public static function isTracked($dbName, $tableName): bool
151151
" AND table_name = '" . $dbi->escapeString($tableName) . "' " .
152152
' ORDER BY version DESC LIMIT 1';
153153

154-
$result = $dbi->fetchValue($sqlQuery, 0, 0, DatabaseInterface::CONNECT_CONTROL) == 1;
154+
$result = $dbi->fetchValue($sqlQuery, 0, DatabaseInterface::CONNECT_CONTROL) == 1;
155155

156156
self::$trackingCache[$dbName][$tableName] = $result;
157157

‎libraries/classes/UserPreferences.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public function save(array $config_array)
141141
. $dbi->escapeString($relationParameters->user)
142142
. '\'';
143143

144-
$has_config = $dbi->fetchValue($query, 0, 0, DatabaseInterface::CONNECT_CONTROL);
144+
$has_config = $dbi->fetchValue($query, 0, DatabaseInterface::CONNECT_CONTROL);
145145
$config_data = json_encode($config_array);
146146
if ($has_config) {
147147
$query = 'UPDATE ' . $query_table

0 commit comments

Comments
 (0)