Link COUNT(*) result to listing
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1358 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
parent
13843b24e5
commit
35ec64c61d
|
@ -135,9 +135,9 @@ function get_vals($query, $column = 0) {
|
||||||
/** Find unique identifier of a row
|
/** Find unique identifier of a row
|
||||||
* @param array
|
* @param array
|
||||||
* @param array result of indexes()
|
* @param array result of indexes()
|
||||||
* @return string query string
|
* @return array
|
||||||
*/
|
*/
|
||||||
function unique_idf($row, $indexes) {
|
function unique_array($row, $indexes) {
|
||||||
foreach ($indexes as $index) {
|
foreach ($indexes as $index) {
|
||||||
if (ereg("PRIMARY|UNIQUE", $index["type"])) {
|
if (ereg("PRIMARY|UNIQUE", $index["type"])) {
|
||||||
$return = array();
|
$return = array();
|
||||||
|
@ -145,7 +145,7 @@ function unique_idf($row, $indexes) {
|
||||||
if (!isset($row[$key])) { // NULL is ambiguous
|
if (!isset($row[$key])) { // NULL is ambiguous
|
||||||
continue 2;
|
continue 2;
|
||||||
}
|
}
|
||||||
$return[] = urlencode("where[" . bracket_escape($key) . "]") . "=" . urlencode($row[$key]);
|
$return[$key] = $row[$key];
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
@ -153,7 +153,7 @@ function unique_idf($row, $indexes) {
|
||||||
$return = array();
|
$return = array();
|
||||||
foreach ($row as $key => $val) {
|
foreach ($row as $key => $val) {
|
||||||
if (!preg_match('~^(COUNT\\((\\*|(DISTINCT )?`(?:[^`]|``)+`)\\)|(AVG|GROUP_CONCAT|MAX|MIN|SUM)\\(`(?:[^`]|``)+`\\))$~', $key)) { //! columns looking like functions
|
if (!preg_match('~^(COUNT\\((\\*|(DISTINCT )?`(?:[^`]|``)+`)\\)|(AVG|GROUP_CONCAT|MAX|MIN|SUM)\\(`(?:[^`]|``)+`\\))$~', $key)) { //! columns looking like functions
|
||||||
$return[] = (isset($val) ? urlencode("where[" . bracket_escape($key) . "]") . "=" . urlencode($val) : "null%5B%5D=" . urlencode($key));
|
$return[$key] = $val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
|
|
|
@ -205,8 +205,12 @@ if (!$columns) {
|
||||||
}
|
}
|
||||||
echo ($backward_keys ? "<th>" . lang('Relations') : "") . "</thead>\n";
|
echo ($backward_keys ? "<th>" . lang('Relations') : "") . "</thead>\n";
|
||||||
foreach ($adminer->rowDescriptions($rows, $foreign_keys) as $n => $row) {
|
foreach ($adminer->rowDescriptions($rows, $foreign_keys) as $n => $row) {
|
||||||
$unique_idf = implode('&', unique_idf($rows[$n], $indexes));
|
$unique_array = unique_array($row, $indexes);
|
||||||
echo "<tr" . odd() . "><td>" . checkbox("check[]", $unique_idf, in_array($unique_idf, (array) $_POST["check"]), "", "this.form['all'].checked = false; formUncheck('all-page');") . (count($select) != count($group) || information_schema(DB) ? '' : " <a href='" . h(ME . "edit=" . urlencode($TABLE) . "&$unique_idf") . "'>" . lang('edit') . "</a>");
|
$unique_idf = "";
|
||||||
|
foreach ($unique_array as $key => $val) {
|
||||||
|
$unique_idf .= "&" . (isset($val) ? urlencode("where[" . bracket_escape($key) . "]") . "=" . urlencode($val) : "null%5B%5D=" . urlencode($key));
|
||||||
|
}
|
||||||
|
echo "<tr" . odd() . "><td>" . checkbox("check[]", substr($unique_idf, 1), in_array(substr($unique_idf, 1), (array) $_POST["check"]), "", "this.form['all'].checked = false; formUncheck('all-page');") . (count($select) != count($group) || information_schema(DB) ? '' : " <a href='" . h(ME . "edit=" . urlencode($TABLE) . $unique_idf) . "'>" . lang('edit') . "</a>");
|
||||||
foreach ($row as $key => $val) {
|
foreach ($row as $key => $val) {
|
||||||
if (isset($names[$key])) {
|
if (isset($names[$key])) {
|
||||||
$field = $fields[$key];
|
$field = $fields[$key];
|
||||||
|
@ -219,7 +223,7 @@ if (!$columns) {
|
||||||
$val = "<i>NULL</i>";
|
$val = "<i>NULL</i>";
|
||||||
} else {
|
} else {
|
||||||
if (ereg('blob|binary', $field["type"]) && $val != "") {
|
if (ereg('blob|binary', $field["type"]) && $val != "") {
|
||||||
$link = h(ME . 'download=' . urlencode($TABLE) . '&field=' . urlencode($key) . "&$unique_idf");
|
$link = h(ME . 'download=' . urlencode($TABLE) . '&field=' . urlencode($key) . $unique_idf);
|
||||||
}
|
}
|
||||||
if ($val == "") {
|
if ($val == "") {
|
||||||
$val = " ";
|
$val = " ";
|
||||||
|
@ -240,6 +244,14 @@ if (!$columns) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ($key == "COUNT(*)") { //! columns looking like functions
|
||||||
|
$link = h(ME . "select=" . urlencode($TABLE));
|
||||||
|
$i = 0;
|
||||||
|
foreach ($unique_array as $k => $v) {
|
||||||
|
$link .= h("&where[$i][col]=" . urlencode($k) . "&where[$i][op]=" . (isset($v) ? "%3D&where[$i][val]=" . urlencode($v) : "IS+NULL"));
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!$link && is_email($val)) {
|
if (!$link && is_email($val)) {
|
||||||
$link = "mailto:$val";
|
$link = "mailto:$val";
|
||||||
|
|
Loading…
Reference in a new issue