Code Duplication    Length = 14-17 lines in 3 locations

install/upgrade_run_2.1.26.php 1 location

@@ 123-136 (lines=14) @@
120
    }
121
}
122
123
function addIndexIfNotExist($table, $index, $sql)
124
{
125
    global $db_link;
126
127
    $mysqli_result = mysqli_query($db_link, "SHOW INDEX FROM $table WHERE key_name LIKE \"$index\"");
128
    $res = mysqli_fetch_row($mysqli_result);
129
130
    // if index does not exist, then add it
131
    if (!$res) {
132
        $res = mysqli_query($db_link, "ALTER TABLE `$table` ".$sql);
133
    }
134
135
    return $res;
136
}
137
138
// add field timestamp to cache table
139
$res = addColumnIfNotExist(

install/upgrade_run_db_original.php 1 location

@@ 59-75 (lines=17) @@
56
    return false;
57
}
58
59
function addIndexIfNotExist($table, $index, $sql)
60
{
61
    global $db_link;
62
63
    $mysqli_result = mysqli_query($db_link, "SHOW INDEX FROM $table WHERE key_name LIKE \"$index\"");
64
    $res = mysqli_fetch_row($mysqli_result);
65
66
    // if index does not exist, then add it
67
    if (!$res) {
68
        $res = mysqli_query(
69
            $db_link,
70
            "ALTER TABLE `$table` ".$sql
71
        );
72
    }
73
74
    return $res;
75
}
76
77
function tableExists($tablename)
78
{

install/upgrade_ajax.php 1 location

@@ 146-159 (lines=14) @@
143
    }
144
}
145
146
function addIndexIfNotExist($table, $index, $sql)
147
{
148
    global $db_link;
149
150
    $mysqli_result = mysqli_query($db_link, "SHOW INDEX FROM $table WHERE key_name LIKE \"$index\"");
151
    $res = mysqli_fetch_row($mysqli_result);
152
153
    // if index does not exist, then add it
154
    if (!$res) {
155
        $res = mysqli_query($db_link, "ALTER TABLE `$table` ".$sql);
156
    }
157
158
    return $res;
159
}
160
161
function tableExists($tablename)
162
{