// 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, "-- "));
function quote($string) {
return (is_utf8($string)
? "'" . $this->link->escapeString($string) . "'"
- : "x'" . reset(unpack('H*', $string)) . "'"
+ : "x'" . first(unpack('H*', $string)) . "'"
);
}
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
$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;
}
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()