Code Duplication    Length = 14-17 lines in 3 locations

install/upgrade_ajax.php 1 location

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

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
{