mirror of
https://github.com/vrana/adminer.git
synced 2025-08-06 14:46:36 +02:00
Notices: Add helper for reset() with expression
This commit is contained in:
@@ -876,7 +876,7 @@ AND typelem = 0"
|
||||
// sequences for fields
|
||||
if (preg_match('~nextval\(\'([^\']+)\'\)~', $field['default'], $matches)) {
|
||||
$sequence_name = $matches[1];
|
||||
$sq = reset(get_rows((min_version(10)
|
||||
$sq = first(get_rows((min_version(10)
|
||||
? "SELECT *, cache_size AS cache_value FROM pg_sequences WHERE schemaname = current_schema() AND sequencename = " . q(idf_unescape($sequence_name))
|
||||
: "SELECT * FROM $sequence_name"
|
||||
), null, "-- "));
|
||||
|
@@ -34,7 +34,7 @@ if (isset($_GET["sqlite"])) {
|
||||
function quote($string) {
|
||||
return (is_utf8($string)
|
||||
? "'" . $this->link->escapeString($string) . "'"
|
||||
: "x'" . reset(unpack('H*', $string)) . "'"
|
||||
: "x'" . first(unpack('H*', $string)) . "'"
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -847,6 +847,15 @@ function file_unlock($fp) {
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
/** Get first element of an array
|
||||
* @param array
|
||||
* @return mixed or false if not found
|
||||
*/
|
||||
function first($array) {
|
||||
// reset(f()) triggers a notice
|
||||
return reset($array);
|
||||
}
|
||||
|
||||
/** Read password from file adminer.key in temporary directory or create one
|
||||
* @param bool
|
||||
* @return string or false if the file can not be created
|
||||
|
@@ -491,7 +491,7 @@ if (!$columns && support("table")) {
|
||||
$found_rows = ($is_group ? false : found_rows($table_status, $where));
|
||||
if ($found_rows < max(1e4, 2 * ($page + 1) * $limit)) {
|
||||
// slow with big tables
|
||||
$found_rows = reset(slow_query(count_rows($TABLE, $where, $is_group, $group)));
|
||||
$found_rows = first(slow_query(count_rows($TABLE, $where, $is_group, $group)));
|
||||
} else {
|
||||
$exact_count = false;
|
||||
}
|
||||
|
@@ -42,7 +42,7 @@ if (!$error && $_POST) {
|
||||
|
||||
if ($query != "" && strlen($query) < 1e6) { // don't add big queries
|
||||
$q = $query . (preg_match("~;[ \t\r\n]*\$~", $query) ? "" : ";"); //! doesn't work with DELIMITER |
|
||||
if (!$history || reset(end($history)) != $q) { // no repeated queries
|
||||
if (!$history || first(end($history)) != $q) { // no repeated queries
|
||||
restart_session();
|
||||
$history[] = array($q, time()); //! add elapsed time
|
||||
set_session("queries", $history_all); // required because reference is unlinked by stop_session()
|
||||
|
Reference in New Issue
Block a user