Code Duplication    Length = 6-9 lines in 2 locations

class/SwDatabase.php 2 locations

@@ 504-512 (lines=9) @@
501
        if (0 == $status) {
502
            $sql    = 'INSERT INTO ' . $GLOBALS['xoopsDB']->prefix('smallworld_friends') . " (id,me,you,status,date) VALUES ('', '" . $userid . "', '" . $friendid . "', '1', UNIX_TIMESTAMP())";
503
            $result = $GLOBALS['xoopsDB']->queryF($sql);
504
        } elseif ($status > 0) {
505
            $sql     = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('smallworld_friends') . " WHERE me = '" . (int)$friendid . "' AND you = '" . (int)$userid . "'";
506
            $sql2    = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('smallworld_friends') . " WHERE me = '" . (int)$userid . "' AND you = '" . (int)$friendid . "'";
507
            $result  = $GLOBALS['xoopsDB']->queryF($sql);
508
            $result = $result && $GLOBALS['xoopsDB']->queryF($sql2);
509
510
            // Since friendship is canceled also following is deleted
511
            $this->toogleFollow(1, $userid, $friendid);
512
        }
513
514
        return $result ? true : false;
515
    }
@@ 559-564 (lines=6) @@
556
            $query2 = 'INSERT INTO ' . $GLOBALS['xoopsDB']->prefix('smallworld_friends') . " (id,me,you,status,date) VALUES ('', '" . $myUid . "', '" . $friend . "', '2', UNIX_TIMESTAMP())";
557
            $result = $GLOBALS['xoopsDB']->queryF($query);
558
            $result = $result && $GLOBALS['xoopsDB']->queryF($query2);
559
        } elseif (0 > $stat) {
560
            $query  = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('smallworld_friends') . " WHERE me = '" . (int)$friend . "' AND you = '" . (int)$myUid . "'";
561
            $query2 = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('smallworld_friends') . " WHERE you = '" . (int)$friend . "' AND me = '" . (int)$myUid . "'";
562
            $result = $GLOBALS['xoopsDB']->queryF($query);
563
            $result = $result && $GLOBALS['xoopsDB']->queryF($query2);
564
        }
565
        return $result ? true : false;
566
    }
567