Code Duplication    Length = 17-17 lines in 4 locations

class/stats.php 1 location

@@ 524-540 (lines=17) @@
521
     *
522
     * @return bool
523
     */
524
    public function dropIndex($index = null)
525
    {
526
        if (empty($index)) {
527
            return false;
528
        }
529
        if (!$this->showIndex($index)) {
530
            return false;
531
        } // index is not exist
532
        $sql = "ALTER TABLE {$this->table} DROP INDEX {$index}";
533
        if (!$result = $this->db->queryF($sql)) {
534
            xoops_error($this->db->error() . '<br>' . $sql);
535
536
            return false;
537
        }
538
539
        return true;
540
    }
541
542
    /**
543
     * Change Index = Drop index + Add Index

class/log.php 3 locations

@@ 1249-1265 (lines=17) @@
1246
     *
1247
     * @return bool
1248
     */
1249
    public function addField($field = null, $structure = null)
1250
    {
1251
        if (empty($field) || empty($structure)) {
1252
            return false;
1253
        }
1254
        if ($this->showFields($field)) {
1255
            return false;
1256
        } // field is exist
1257
        $sql = "ALTER TABLE {$this->table} ADD {$field} {$structure}";
1258
        if (!$result = $this->db->queryF($sql)) {
1259
            xoops_error($this->db->error() . '<br>' . $sql);
1260
1261
            return false;
1262
        }
1263
1264
        return true;
1265
    }
1266
1267
    /**
1268
     * Drop Field in a table
@@ 1277-1293 (lines=17) @@
1274
     *
1275
     * @return bool
1276
     */
1277
    public function dropField($field = null)
1278
    {
1279
        if (empty($field)) {
1280
            return false;
1281
        }
1282
        if (!$this->showFields($field)) {
1283
            return false;
1284
        } // field is not exist
1285
        $sql = "ALTER TABLE {$this->table} DROP {$field}";
1286
        if (!$result = $this->db->queryF($sql)) {
1287
            xoops_error($this->db->error() . '<br>' . $sql);
1288
1289
            return false;
1290
        }
1291
1292
        return true;
1293
    }
1294
1295
    /**
1296
     * Show index in a table
@@ 1369-1385 (lines=17) @@
1366
     *
1367
     * @return bool
1368
     */
1369
    public function dropIndex($index = null)
1370
    {
1371
        if (empty($index)) {
1372
            return false;
1373
        }
1374
        if (!$this->showIndex($index)) {
1375
            return false;
1376
        } // index is not exist
1377
        $sql = "ALTER TABLE {$this->table} DROP INDEX {$index}";
1378
        if (!$result = $this->db->queryF($sql)) {
1379
            xoops_error($this->db->error() . '<br>' . $sql);
1380
1381
            return false;
1382
        }
1383
1384
        return true;
1385
    }
1386
1387
    /**
1388
     * Change Index = Drop index + Add Index