Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

Diff of /adminer/indexes.inc.php [c8248b] .. [5f3709] Maximize Restore

  Switch to unified view

a/adminer/indexes.inc.php b/adminer/indexes.inc.php
...
...
17
    foreach ($row["indexes"] as $index) {
17
    foreach ($row["indexes"] as $index) {
18
        $name = $index["name"];
18
        $name = $index["name"];
19
        if (in_array($index["type"], $index_types)) {
19
        if (in_array($index["type"], $index_types)) {
20
            $columns = array();
20
            $columns = array();
21
            $lengths = array();
21
            $lengths = array();
22
          $descs = array();
22
            $set = array();
23
            $set = array();
23
            ksort($index["columns"]);
24
            ksort($index["columns"]);
24
            foreach ($index["columns"] as $key => $column) {
25
            foreach ($index["columns"] as $key => $column) {
25
                if ($column != "") {
26
                if ($column != "") {
26
                    $length = $index["lengths"][$key];
27
                    $length = $index["lengths"][$key];
28
                  $desc = $index["descs"][$key];
27
                    $set[] = idf_escape($column) . ($length ? "(" . (+$length) . ")" : "");
29
                    $set[] = idf_escape($column) . ($length ? "(" . (+$length) . ")" : "") . ($desc ? " DESC" : "");
28
                    $columns[] = $column;
30
                    $columns[] = $column;
29
                    $lengths[] = ($length ? $length : null);
31
                    $lengths[] = ($length ? $length : null);
32
                  $descs[] = $desc;
30
                }
33
                }
31
            }
34
            }
32
            
35
            
33
            if ($columns) {
36
            if ($columns) {
34
                $existing = $indexes[$name];
37
                $existing = $indexes[$name];
35
                if ($existing) {
38
                if ($existing) {
36
                    ksort($existing["columns"]);
39
                    ksort($existing["columns"]);
37
                    ksort($existing["lengths"]);
40
                    ksort($existing["lengths"]);
38
                  if ($index["type"] == $existing["type"] && array_values($existing["columns"]) === $columns && (!$existing["lengths"] || array_values($existing["lengths"]) === $lengths)) {
41
                  ksort($existing["descs"]);
42
                  if ($index["type"] == $existing["type"]
43
                      && array_values($existing["columns"]) === $columns
44
                      && (!$existing["lengths"] || array_values($existing["lengths"]) === $lengths)
45
                      && array_values($existing["descs"]) === $descs
46
                  ) {
39
                        // skip existing index
47
                        // skip existing index
40
                        unset($indexes[$name]);
48
                        unset($indexes[$name]);
41
                        continue;
49
                        continue;
42
                    }
50
                    }
43
                }
51
                }
...
...
64
        if ($index["columns"][count($index["columns"])] != "") {
72
        if ($index["columns"][count($index["columns"])] != "") {
65
            $row["indexes"][$key]["columns"][] = "";
73
            $row["indexes"][$key]["columns"][] = "";
66
        }
74
        }
67
    }
75
    }
68
    $index = end($row["indexes"]);
76
    $index = end($row["indexes"]);
69
  if ($index["type"] || array_filter($index["columns"], 'strlen') || array_filter($index["lengths"], 'strlen')) {
77
  if ($index["type"]
78
      || array_filter($index["columns"], 'strlen')
79
      || array_filter($index["lengths"], 'strlen')
80
      || array_filter($index["descs"])
81
  ) {
70
        $row["indexes"][] = array("columns" => array(1 => ""));
82
        $row["indexes"][] = array("columns" => array(1 => ""));
71
    }
83
    }
72
}
84
}
73
if (!$row) {
85
if (!$row) {
74
    foreach ($indexes as $key => $index) {
86
    foreach ($indexes as $key => $index) {
...
...
90
    ksort($index["columns"]);
102
    ksort($index["columns"]);
91
    
103
    
92
    $i = 1;
104
    $i = 1;
93
    foreach ($index["columns"] as $key => $column) {
105
    foreach ($index["columns"] as $key => $column) {
94
        echo "<span>" . html_select("indexes[$j][columns][$i]", array(-1 => "") + $fields, $column, ($i == count($index["columns"]) ? "indexesAddColumn" : "indexesChangeColumn") . "(this, '" . js_escape($jush == "sql" ? "" : $_GET["indexes"] . "_") . "');");
106
        echo "<span>" . html_select("indexes[$j][columns][$i]", array(-1 => "") + $fields, $column, ($i == count($index["columns"]) ? "indexesAddColumn" : "indexesChangeColumn") . "(this, '" . js_escape($jush == "sql" ? "" : $_GET["indexes"] . "_") . "');");
95
      echo "<input type='number' name='indexes[$j][lengths][$i]' class='size' value='" . h($index["lengths"][$key]) . "'> </span>"; //! hide for non-MySQL drivers, add ASC|DESC
107
      echo ($jush == "sql" || $jush == "mssql" ? "<input type='number' name='indexes[$j][lengths][$i]' class='size' value='" . h($index["lengths"][$key]) . "'>" : "");
108
      echo ($jush != "sql" ? checkbox("indexes[$j][descs][$i]", 1, $index["descs"][$key], lang('descending')) : "");
109
      echo " </span>";
96
        $i++;
110
        $i++;
97
    }
111
    }
98
    
112
    
99
    echo "<td><input name='indexes[$j][name]' value='" . h($index["name"]) . "' autocapitalize='off'>\n";
113
    echo "<td><input name='indexes[$j][name]' value='" . h($index["name"]) . "' autocapitalize='off'>\n";
100
    $j++;
114
    $j++;